Android, How to remove all markers from Google Map V2?

后端 未结 5 1313
刺人心
刺人心 2020-12-25 10:04

I have map view in my fragment. I need to refresh map and add different markers based on condition. So, I should remove last markers from map before add new markers.

5条回答
  •  情深已故
    2020-12-25 10:44

    If you need to remove only the markers, and leave other things such as ground overlay,etc there, use:

     marker.remove();
    

    or if you have many:

     if(markers!=null&&mMap!=null){                          
          for(int i=0;i

    where

    List markers = new ArrayList<>();
    

提交回复
热议问题