<!DOCTYPE html> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>地址解析</title><style type="text/css">* {margin: 0px;padding: 0px;}body,button,input,select,textarea {font: 12px/16px Verdana, Helvetica, Arial, sans-serif;}p {width: 603px;padding-top: 3px;margin-top: 10px;overflow: hidden;}input#address {width: 300px;}</style><script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script></head><body onload="init()"><script>var geocoder = null;var init = function() {geocoder = new qq.maps.Geocoder();}function codeAddress() {var address = document.getElementById("address").value;//对指定地址进行解析 geocoder.getLocation(address);//设置服务请求成功的回调函数 geocoder.setComplete(function(result) {alert(result.detail.location);});//若服务请求失败,则运行以下函数 geocoder.setError(function() {alert("出错了,请输入正确的地址!!!");});}</script><div><input id="address" type="textbox" value="中国,北京,海淀区,海淀大街38号"><button onclick="codeAddress()">search</button></div> </body></html>