var markersArray = new Array();
function clearOverlays(){
if(markersArray){
for (i in markersArray) {
markersArray[i].setMap(null);
}
}
}
this is pretty much copied off the google maps v3 documentation... but it doesn't work. :/
this is where the function is implemented:
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);
}
});
}
and this is the bit where I add the marker in the addMarker function:
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);
});
Any help will be excellent... thank you.