just create a method as clearOverlays()
and inside the method
public void clearOverlays(){ if(mMap!=null){ mMap.clear(); }else{ Log.d("Maps::","mMap is null"); } }
where mMap
public static GoogleMap mMap;
That mMap will be automatically initialized inside public void onMapReady(GoogleMap googleMap) .
This is where mMap = googleMap;
Now use the clearOverlays() method clearOverlays() you want.
Sukirti dash
source share