1

I have a method to a add markers to google map v2 and i wish to clear the markers and then add more markers all while in the map. This is how i add the markers which works fine mapLoc being the map itself. Further down the line i then call mapLoc.clear which gets rid of the markers.

I then wish to add more markers to the map but the markers dont appear when i call this method any help?

        for(int i=0;i<list.size();i++){

           LatLng lg=new LatLng(Float.parseFloat(list.get(i).get(5)), Float.parseFloat(list.get(i).get(6)));

           Marker mark= mapLoc.addMarker(new MarkerOptions().position(lg)
                .title(list.get(i).get(0)).snippet(list.get(i).get(1)).icon(BitmapDescriptorFactory
                          .fromResource(R.drawable.mark2)));
        counter++;
        }
RobFos
  • 17
  • 5
  • Try to save your `Marker` object in the `HashMap`, and then calling `markers.remove()` instead of `map.clear`, finally use your code above to add `additional markers`. For more details, please refer to [here](http://stackoverflow.com/questions/13692398/remove-a-marker-from-a-googlemap). – bjiang Feb 12 '15 at 01:11
  • hrmm seems like a better way of doing it thanks man – RobFos Feb 12 '15 at 10:01

1 Answers1

2

As we discuss above:

Try to save your Marker object in the HashMap, and then calling markers.remove() instead of map.clear, finally use your code above to add additional markers.

For more details, please refer to here.

Community
  • 1
  • 1
bjiang
  • 6,068
  • 2
  • 22
  • 35