2012-05-05 37 views
1

我試圖在Google Maps API v3上弄髒我的手。但是現在我一直想搞清楚如何獲得某個標記的座標?有沒有辦法在Google Maps中獲取標記的座標?

<script> 

    var homeLatlng = new google.maps.LatLng(16.61096000671, 120.31346130371); 
    var homeMarker = new google.maps.Marker({ 
     position: homeLatlng, 
     map: map 
    }); 

    var myOptions = { 
     center: new google.maps.LatLng(16.61096000671, 120.31346130371), 
     zoom: 10, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 

    var map = 
     new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

    //I know that I'm the one who set the coordinates for this, 
    // but how do I fetch it back? 

    $('#plot').click(function(){ 
     homeMarker.setMap(map); 
    }); 

</script> 
+0

正好有它得心應手,谷歌地圖V3 [API參考](https://developers.google.com/maps/documentation/javascript/reference)大約有你可以做什麼更多信息與[google.maps.Marker](https://developers.google.com/maps/documentation/javascript/reference#Marker) –

回答

4
homeMarker.getPosition(); //returns a google.maps.LatLng object 
相關問題