下面是我的地理編碼的JavaScript。我的地圖不會出現,我似乎無法找到我的錯誤。請指教。地理編碼沒有出現
我試圖顯示實際位置的「真實」值。 API在Google開發人員網站上正確生成。
<script>
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.Latlng(-34.397, 150.644);
var mapOptions = {
zoom: 8,
Center: latlng
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}
function codeAddress() {
var address = document.get.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);
}
});
}
</script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=drawing&sensor=true"></script>
請提供足夠的代碼/ HTML到重現這個問題(或者是一個jsfiddle或者是一個顯示問題的地圖的鏈接)。 – geocodezip
修復你的javascript錯誤。 – geocodezip