本文介绍了谷歌地图API V2由ID找到标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以简单地与Android上的新V2谷歌地图API添加标记。由于标记是在配置改变或保存例如重新创建,你必须通过它的ID来引用它们。现在的问题是如何从与特定的ID地图标记删除?

You can simply add Markers with the new V2 Google maps API on Android. Because the Markers are recreated on configuration change or on save instance, you have to reference them via its ids. The question is how to remove from map Marker with particular id?

我的用例是标记添加到地图中,存储其ID与映射真实的物体。然后,用户将删除这个现实对象之一,所以我找了标记ID,并希望从地图,我知道是有标记对象并调用remove()方法的唯一方式删除标记。

My use case is to add Markers to the map, store its id's with mapping to real objects. Then user removes one of this real objects, so I find the Marker id and want to remove Marker from the map and the only way I know about is to have Marker object and call remove() on it.

推荐答案

该文档是错的有关配置更改标记重建,它实际上是对我们有好处,这是错误的存在。

The documentation is wrong about recreating markers on configuration change and it's actually good for us it is wrong there.

这篇关于谷歌地图API V2由ID找到标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 16:05