How to remove single marker using Google Maps V2?

Alexey Zakharov picture Alexey Zakharov · Dec 4, 2012 · Viewed 98k times · Source

The only method that removes markers from map is clear. However it clears all markers from the map.

I want to remove only single marker or group of markers.

How could i achieve this?

Answer

Alexey Zakharov picture Alexey Zakharov · Dec 4, 2012

After adding the marker it is possible to obtain its reference:

Marker marker = map.addMarker(..);

The Marker class has a remove method: