每次用户单击地图时在地图视图上放置可绘制标记的有效方法是什么
我正在使用 Android MapView 并遇到一个要求,我必须在用户单击的位置放置一个标记。 在我的场景中,用户可以平移地图、放大和缩小,然后单击她喜欢的任何位置。 在这种情况下,标记应放置在用户单击地图的任何位置。 如果地图上有先前的标记,则在单击事件时应将其清除并放置在新位置。 每次案例重复时都应该重复此操作。
将来,我将有更多的可绘制对象,例如范围代表和用于选择可以拖动的范围的指针。
我可以将标记放在第一个位置,但是当用户单击其他任何地方时,我的代码不起作用。
这是我正在使用的类的代码: http://pastebin.com/6idn7VwK 扩展 MapActivity 的完整类和扩展 ItemizedOverlay 的完整类可以在上面的链接中找到。
我知道我可能做错了一些事情,所以请纠正我。
谢谢!
I am playing around with Android MapView and have come across a requirement, where i have to put a marker at the place where the user clicks.
in my scenario, the user can pan a map , zoom in and out, and click wherever she likes.
in this case, the marker should be put wherever the user is clicking on the map.
If a previous marker was there on map, then at click event it should be cleared and be put at the new place.
This should repeat every time the case repeats.
In future, I'll be having some more drawables like range representative and a pointer to select range which can be dragged.
I am able to put the marker on the first place, but my code doesn't work when the user clicks anywhere else.
Here's the code for the class that I am using: http://pastebin.com/6idn7VwK
The full class extending MapActivity and the one extending the ItemizedOverlay can be found in the link above.
I understand that I might be doing some wrong things, so please correct me.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该为此类功能重写 onTap 方法:
You should override the onTap method for this type of functionality :