在地图上创建自定义叠加层
我正在尝试在 Android 中复制地图的此功能:
您可以看到,在地图上,有一个圆圈描绘了用户选择的范围。
在我的应用程序中,我还希望在圆的周边放置一个拖动器,可以拖动它来重新定义半径。
如果有人可以告诉我如何在地图上绘制自定义可绘制叠加层和 2D 图形,我就可以自己做其他事情。
谢谢!
完整的申请可以通过此链接获取
I am trying to replicate this feature of Maps in Android:
You can see that on the map, there's a Circle depicting the range that the user has selected.
In my application, I'll also want a dragger to reside on the perimeter of the circle, which can be dragged to redefine radius.
If someone could tell me how to draw custom drawable overlays and 2D graphics over map, I can do other things on my own.
Thanks!
The full application can be reached at this link
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我尝试自己做事,并输入此代码以获得上述效果:
这让我具有以下效果:
使用的计算可能不是您想要的。
它仅用于演示目的。
实际距离/距离计算也需要使用方位,并且有一些特定的公式。
如果您对此有任何疑问,请告诉我。
Okay, I tried to do things on my Own, and put this code to get the above effect:
This let me have following effect:
The calculation used may not be what you want.
Its just for demonstration purposes.
Real range/distance calculation requires the use of bearing too and has some specific formula.
Let me know if you have any questions regarding this.
扩展类 ItemizedOverlay< /a> 覆盖 draw() 方法。绘制覆盖层的
Canvas
被传递给该方法,您可以调用 drawCircle 或使范围拖动器出现所需的任何内容。Extend the class ItemizedOverlay to override the draw() method. The
Canvas
where overlays are drawn is passed to that method and you can call drawCircle or anything that's needed to make your range dragger appear.用圆圈绘制图钉的示例代码:
An example code to draw a pushpin with the circle: