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 ...
Hover your cursor over the box and wait until more options appear. Click “More” to open the Map Details menu. Under “Map Type,” you'll see a checked box next to “Labels.” Uncheck it to remove all labels.
When you use Google Maps to find a route to a destination, pins mark the starting point and the destination. Depending on the route, pins may also mark locations along the route, including detours. To remove any of these pins, right-click the Pin and select Remove this destination from the drop-down menu.
Use this line: googleMap. clear(); and after add new marker on Google map.
Removing all markers You can then clear all the markers using clearMarkers something like this: markerClusterer. clearMarkers(); markers = [];
RemovingOverlays
markersArray[markersArray.length-1].setMap(null);
... for path:
path = poly.getPath();
path.pop();
PolylineOptions, MVCArray.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With