问题
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?
回答1:
After adding the marker it is possible to obtain its reference:
Marker marker = map.addMarker(..);
The Marker
class has a remove method:
回答2:
I got the same problem, so to fix it I'm doing
mMap = super.getMap();
map.clear();
回答3:
I wrote up a blog post on how to remove Markers when they are moved off the screen, and adding them again when they are on the screen. This is useful if you are trying to add thousands of Markers to a GoogleMap at the same time but don't want the performance to suffer as much as it would if they are all on the map at the same time. It uses the same method you detailed (calling remove() on a Marker).
Hiding and Showing on screen Markers with Google Maps Android API V2
来源:https://stackoverflow.com/questions/13702379/how-to-remove-single-marker-using-google-maps-v2