我有這個JavaScript在我的HTML什麼,我想在這裏做的是讓地圖表示給定位置嘗試使用谷歌API V3從地址獲得位置
<script type="text/javascript">
var geocoder;
var map;
function getmaploc() {
geocoder = new google.maps.Geocoder();
var myOptions = {
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
geocoder.geocode('cairo', 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);
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
});
}
</script>
<body onload="getmaploc()">
<div id="map_canvas" style="width: 320px; height: 480px;"></div>
</body>
我無法弄清楚什麼是錯與此任何幫助?
請格式化你的代碼,很多人(包括我在內),將無法讀取未格式良好的 – 2012-04-23 22:58:22
固定它對不起進出口新的計算器 – 2012-04-23 23:05:55
格式化也爲你的代碼,你*修復*仍然不是很可讀。這裏有另一個提示:「它不起作用」沒有錯誤信息使其他人更難以幫助。 – 2012-04-24 00:37:37