I need to clear all markers in v2 google map. And again need to add some markers. If anybody knows the answer kindly share your thoughts.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
just create a method as
clearOverlays()
and inside the method
where mMap is
That
mMap
will initialize automatically inside thepublic void onMapReady(GoogleMap googleMap)
method .There put
mMap = googleMap;
Now use the
clearOverlays()
method wherever you want.you can use clear() in java and kotlin
java
kotlin
You can either use
googleMap.clear()
, or you can store your Markers in a collection of some kind and remove them in a loop:I think this would be helpful for you. Take all the markers in a List and refresh the map view whenever you need to replace markers by clearing the object of Google Map and List variable.
Use Google Map object and call clear to clear the markers.
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap#clear()
Check the docs
public final void clear ()
Removes all
markers, polylines, polygons, overlays
, etc from the map.ex - if you want to refresh and load new marker point in the map for a button click(in this ex i get button click),