我有一個問題,設置標記並獲得該標記的經度和緯度。我怎樣才能做到谷歌地圖v3 API谷歌地圖API v3集標記和獲取點
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("divGoogleMaps"), myOptions);
google.maps.event.addListener(map, 'click', function() {
});
這是我的開始代碼。
最後這段代碼幫我做了這件事。我可以在地圖上只能有一個標記,這個標記,當用戶cliks在地圖上的「代碼」 google.maps.event.addListener(地圖「點擊」設置功能(事件){ \t \t \t如果(self.marker! = NULL) \t \t \t \t self.marker.setMap(空); \t \t \t self.value =新google.maps.LatLng(event.latLng.lat(),event.latLng.lng()); \t \t \t \t self.marker =新google.maps.Marker({ \t \t \t \t位置:0 self.value\t \t \t}); \t \t \t self.zoom = map.getZoom(); \t \t \t self.marker.setMap(map); \t}); – user821738