spectrum24
28 Nov 2010, 3:14 PM
I've seen lots of examples here on adding map markers, but not how to remove them. I need to remove them all before each refresh. The Google API docs say this:
var markersArray = [];
// Deletes all markers in the array by removing references to them
function deleteOverlays() {
if (markersArray) {
for (i in markersArray) {
markersArray[i].setMap(null);
}
markersArray.length = 0;
}
}
and add a markersArray.push(marker); to the addMarker function, which I did. But when I try deleteOverlays(), I get an error:
TypeError: Result of expression 'markersArray[i].setMap' [undefined] is not a function.
Ive tried variants of this with no success. Anyone know how to make this work within ST?
var markersArray = [];
// Deletes all markers in the array by removing references to them
function deleteOverlays() {
if (markersArray) {
for (i in markersArray) {
markersArray[i].setMap(null);
}
markersArray.length = 0;
}
}
and add a markersArray.push(marker); to the addMarker function, which I did. But when I try deleteOverlays(), I get an error:
TypeError: Result of expression 'markersArray[i].setMap' [undefined] is not a function.
Ive tried variants of this with no success. Anyone know how to make this work within ST?