Search code examples
androidgoogle-mapsgoogle-maps-android-api-2gmsgroundoverlay

Android - Google maps V2 - Removing a groundoverlay


My app uses google maps v2, I add a groundoverlay to my map. Does anyone know how I can remove this overlay?

Thanks

.remove() doesn't seem to available

enter image description here


Solution

  • there is the method remove(): https://developers.google.com/android/reference/com/google/android/gms/maps/model/GroundOverlay.html#remove()

    You just have to keep a reference to the ground overlay when you create it:

     GroundOverlay groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
         .image(image)
         .positionFromBounds(bounds)
         .transparency(0.5));
    

    then remove:

    groundOverlay.remove();