如何在 Android MapView 上绘制当用户放大和缩小时自动调整大小的矩形?
我的 Android 应用程序有一个 MapView。我想根据纬度和经度将该 MapView 划分为网格,并根据特定标准为该网格的不同单元格着色不同的颜色。最简单的方法是什么?
我可以创建半透明、纯色 PNG Drawable 矩形图像,并将它们放入以单元格中心点为中心的 ItemizedOverlay 中,但随后矩形会随着用户在地图上放大和缩小而增大和缩小。我可以扩展 MapView 并覆盖缩放功能,以便在用户缩放时重新调整矩形的大小,但这对于本应简单的事情来说似乎非常复杂!请告诉我更好的方法?
My Android application has a MapView. I want to divide that MapView into a grid according to latitude and longitude, and shade the different cells of that grid different colors based upon a certain criteria. What's the simplest way to do this?
I could create semi-transparent, solid-color PNG Drawable rectangular images and put them in an ItemizedOverlay centered on the central points of the cells, but then the rectangles would grow and shrink as the user zoomed in and out on the map. I could extend MapView and override the zoom functions so that the rectangles got re-sized when the user zoomed, but that seems really complicated for something that should be simple! Please tell me a better way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案:http://www.mail-archive .com/[电子邮件受保护]/msg19804.html
是扩展Overlay,而不是MapView。而且我不必使用 ItemizedOverlays 或 PNG Drawables,这让我松了口气,因为我讨厌这些东西。
I found the answer: http://www.mail-archive.com/[email protected]/msg19804.html
The solutions is to extend Overlay, not MapView. And I don't have to use ItemizedOverlays or PNG Drawables, which is a relief, because I hate those things.