自由形式的绘画与Android地图V2形式、地图、自由、Android

2023-09-04 04:21:22 作者:哥的裤裆里有wifi

我有使用Android的新v2的谷歌地图API的一个地图应用程序。我所要做的是让用户画一条线跟随手指的道路在地图上。我明白我可能会需要一个按钮启用/禁用此功能,因为它显然需要禁用平移/缩放控件。一旦用户绘制其线I需要能够加入端起来,形成一个多边形。是否有人知道如何可以做到这一点?真的AP preciate任何帮助!

I have a maps application using the new v2 Google Maps API for Android. What I am trying to do is allow the user to draw a line on the map that follows the path of their finger. I understand I will probably need a button to enable/disable this functionality as it would obviously need to disable the pan/zoom controls. Once a user draws their line I need to be able to join the ends up to form a polygon. Does anybody know how this can be done? Really appreciate any help!

推荐答案

我想你可以通过使用的FrameLayout是覆盖一个查看地图碎片上面实现这一目标。收听该视图触摸事件,并设置它的知名度GONE一旦用户要关闭绘图所以它不会解雇你的触摸听众,而是火的地图的。

I think you could achieve this by using a framelayout that overlays a view above the map fragment. Listen for touch events on that view and set it's visibility to GONE once the user wants to disable the drawing so it wont fire your touch listeners and instead fire the maps ones.

另一种方法是使用,而不是让自由绘画标记,你可以很容易地监听标记拖动事件和画线,当拖动事件结束。

An alternative would be to use a marker instead of allowing freeform drawing, you can easily listen for marker drag events and draw lines when the drag events finish.

合上多边形将如画线从开始到最后一行的末尾一样容易。

Closing the polygon would be as easy as drawing a line from the start to the last line's end.

这将允许你生在地图 https://developers.google.com /地图/文档/安卓/线