如何在 Android MapView 上绘制当用户放大和缩小时自动调整大小的矩形?

发布于 2024-09-15 16:50:55 字数 266 浏览 3 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云之铃。 2024-09-22 16:50:55

我找到了答案: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文