google Map API实现地址解析
Google map API的地址解析服务目前是不收费的,可以将详细的地址转化成经纬度。
测试HTML文件如下:
<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1.0, user-scalable=no"/><meta http-equiv="content-type" content="text/html; charset=UTF-8"/><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script type="text/javascript"> var geocoder; function initialize() { geocoder = new google.maps.Geocoder(); } function codeAddress() { var address = document.getElementById("address").value; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { alert(results[0].geometry.location); } else { alert("Geocode was not successful for the following reason: " + status); } }); }</script></head><body onload="initialize()"> <div> <input id="address" type="textbox" value="Sydney, NSW"> <input type="button" value="Geocode" onclick="codeAddress()"> </div></body></html>