1

我正在尝试使用 Google Maps API v3。但是现在我一直在弄清楚如何获取某个标记的坐标?

<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>
4

1 回答 1

4
homeMarker.getPosition(); //returns a google.maps.LatLng object
于 2012-05-05T13:28:38.643 回答