【问题标题】:Android - Google maps V2 - Removing a groundoverlayAndroid - Google maps V2 - 移除地面覆盖
【发布时间】:2015-09-24 14:19:03
【问题描述】:

我的应用程序使用谷歌地图 v2,我在我的地图中添加了地面叠加层。有谁知道我可以如何删除此叠加层?

谢谢

.remove() 似乎不可用

【问题讨论】:

    标签: android google-maps google-maps-android-api-2 gmsgroundoverlay


    【解决方案1】:

    有方法remove(): https://developers.google.com/android/reference/com/google/android/gms/maps/model/GroundOverlay.html#remove()

    您只需要在创建地面叠加层时保留对它的引用:

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

    然后删除:

    groundOverlay.remove();
    

    【讨论】:

    • 好吧,我也是这么想的,但 .remove() 似乎不存在:/
    • 仔细阅读答案。在您的屏幕截图中,您尝试在 GroundOverlayOptions 对象上调用 remove()。您需要在GroundOverlay 对象本身上调用remove(),当您调用addGroundOverlay() 方法时会返回该对象。
    • 啊,我明白了!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    相关资源
    最近更新 更多