2013-03-27 55 views
1

我試圖把標記放在簡單地圖示例(http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html)中的位置(-23.426056,-47.599556),而標記從不停留在正確的位置。在Google地圖中,我總是會得到兩個標記,一個是紅色標記(標記街道),另一個是綠色標記(箭頭標記爲正確的位置),就像這張照片http://s4.postimg.org/6ahyt0rm5/ibagen.gif地理編碼谷歌地圖錯誤的位置

我該如何解決這個問題?

回答

1

如果您知道標記所屬的位置(座標),請不要使用地理編碼器,只需將標記放在所需的位置即可。如this example from the Google Maps API v3 documentation 請注意,您發佈的示例使用的是Google Maps API v2,該版本已於2010年5月19日棄用;並在2013年5月19日到期。使用該版本的新開發不鼓勵。

<!DOCTYPE html> 
<html> 
    <head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="utf-8"> 
    <title>Google Maps JavaScript API v3 Example: Marker Simple</title> 
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> 
    <script> 
     function initialize() { 
     var myLatlng = new google.maps.LatLng(-23.426056, -47.599556); 
     var mapOptions = { 
      zoom: 4, 
      center: myLatlng, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     } 
     var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); 

     var marker = new google.maps.Marker({ 
      position: myLatlng, 
      map: map, 
      title: 'Hello World!' 
     }); 
     } 
    </script> 
    </head> 
    <body onload="initialize()"> 
    <div id="map-canvas" style="height:400px; width:500px;"></div> 
    </body> 
</html> 
+0

非常感謝!!!!!!!! – Shermano 2013-03-27 05:54:00