Monday, May 20, 2024
82
rated 0 times [  83] [ 1]  / answers: 1 / hits: 22373  / 13 Years ago, sun, july 17, 2011, 12:00:00

I'm using this function to add a new marker (and polyline) to a map:



 function addMarker(location) {

path = poly.getPath();
path.push(location);
marker = new google.maps.Marker({
position: location,
icon:'location.png',
title: poly.inKm() + ' km',
map: map
});
markersArray.push(marker);
}


How can I remove the last marker (for implementing undo)?



Best regards ...


More From » google-maps-api-3

 Answers
22

RemovingOverlays



markersArray[markersArray.length-1].setMap(null);


... for path:



path = poly.getPath();
path.pop();


PolylineOptions, MVCArray.


[#91146] Friday, July 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cierra

Total Points: 504
Total Questions: 108
Total Answers: 109

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
;