2
我正嘗試使用Google地圖地理編碼服務。我複製了代碼,它似乎找到了很好的地址(例如「13 Marine Terrace Aberystwyth」),但沒有像「Rummers Wine Bar,Aberystwyth」這樣的其他地方,儘管實際的Google Maps網站完全沒有問題。Google地圖解析器找不到與Google地圖網站不同的地址,這些地址不是準確的地址
這是我的代碼,稍加修改是對阿伯里斯特威斯地區,但以其他方式複製形式https://developers.google.com/maps/documentation/javascript/tutorial
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript"
/*you can use https if you want it secure!!! set java scrip sensor to true and read from gps!*/
src="http://maps.googleapis.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXo-tdDimvjIs&sensor=false®ion=GB">
</script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(52.4156, -4.0829);
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
function code()
{document.write(results[0].geometry.location);}
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width: 320px; height: 480px;"></div>
<div>
<input id="address" type="textbox" value="aberystwyth">
<input type="button" value="Encode" onclick="codeAddress()">
</div>
</script>
<script type="text/javascript">
code();
</script>
</body>
這是一個鏈接:http://users.aber.ac.uk/avh9/thesite/geocodeaber.html
誰能告訴我爲什麼以及如何解決它?或任何替代地理編碼....
我不認爲他們的公共地理編碼API處理商業名稱或地標名稱,但只是郵政地址。 – Nadh 2012-04-26 16:26:12