var markersArray = new Array();
function clearOverlays(){
if(markersArray){
for (i in markersArray) {
markersArray[i].setMap(null);
}
}
}
這是非常複製谷歌地圖v3文檔...但它不起作用。 :/Javascript谷歌地圖V3 - 爲什麼這不清除覆蓋功能的工作?
這是那裏的功能實現:
function TCGetLatLong(address){
var geo = new google.maps.Geocoder;
var lat;
var lng;
geo.geocode({'address':address},function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
clearOverlays();
addMarker(results[0].geometry.location, true, true, 16, "new", 0, "", "");
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
而這正是我在addMarker函數添加標記位:
marker = new google.maps.Marker({
position: location,
draggable: draggable,
title: "Your new listing",
map: map
});
markersArray.push(marker);
google.maps.event.addListener(marker, 'dragend', function() {
infowindow.open(map,marker);
document.getElementById('lat').value = marker.position.lat();
document.getElementById('long').value = marker.position.lng();
});
google.maps.event.addListener(marker, 'dragstart', function(){ infowindow.close(); });
infowindow.open(map,marker);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
任何幫助將是極好的.. 。 謝謝。