如何清除v2的谷歌地图的所有标记? [英] How to clear all the markers in v2 google map?

查看:875
本文介绍了如何清除v2的谷歌地图的所有标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要清除v2的谷歌地图的所有标记。又一次需要添加一些标记。如果有人知道答案亲切交流你的看法。

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.

推荐答案

您可以使用<一个href=\"https://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html#clear%28%29\"><$c$c>googleMap.clear(),或者您可以将您的标记某种形式的集合,并在一个循环中删除:

You can either use googleMap.clear(), or you can store your Markers in a collection of some kind and remove them in a loop:

private ArrayList<Marker> mMarkers;
...
private void removeMarkers() {
    for (Marker marker: mMarkers) {
        marker.remove();
    }
    mMarkers.clear();
}

这篇关于如何清除v2的谷歌地图的所有标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆