Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove marker in Google Maps Api v3

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 ...

like image 395
fillibuster Avatar asked Jul 17 '11 19:07

fillibuster


People also ask

Can you turn off markers in Google Maps?

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.

How do I remove a pointer from Google Maps?

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.

How do I remove a location marker?

Use this line: googleMap. clear(); and after add new marker on Google map.

How do I remove a marker cluster from Google Maps?

Removing all markers You can then clear all the markers using clearMarkers something like this: markerClusterer. clearMarkers(); markers = [];


1 Answers

RemovingOverlays

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

... for path:

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

PolylineOptions, MVCArray.

like image 134
rebeliagamer Avatar answered Oct 06 '22 21:10

rebeliagamer