Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove single marker using Google Maps V2? [duplicate]

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?

like image 460
Alexey Zakharov Avatar asked Dec 04 '12 11:12

Alexey Zakharov


People also ask

How do you delete a marker on Google Maps?

You can delete the markers by removing them from the map and then setting the array's length to 0 , which removes all references to the markers.

How do you erase a map pen?

The non-permanent ink can be wiped off using a damp cloth, but your markings may not survive a rain storm. The permanent ink will easily survive getting wet, but minor erasures can be made with a plastic eraser, and the sheet can be wiped clean with a cloth dampened with alcohol.

How do I remove a location marker?

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


2 Answers

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

Marker marker = map.addMarker(..); 

The Marker class has a remove method:

like image 192
Alexey Zakharov Avatar answered Nov 16 '22 00:11

Alexey Zakharov


I got the same problem, so to fix it I'm doing

mMap = super.getMap(); map.clear(); 
like image 36
douarbou Avatar answered Nov 16 '22 02:11

douarbou