ItemizedOverlay.draw() 的性能问题

发布于 2024-11-09 02:34:18 字数 592 浏览 0 评论 0原文

我有一个类:

public class WaypointOverlay extends ItemizedOverlay<OverlayItem>

它重写了 ItemizedOverlaydraw() 方法。
在我的活动中,我有一张包含许多覆盖项目和列表的地图。我从 Traceviewer 输出和 logcat 中注意到,即使地图未受影响,MapView.onDraw() 也会被多次调用。这导致列表和地图确实没有响应(当我的 WaypointOverlay 类只是从这些 onDraw 调用返回时,一切都表现良好)

我怎样才能拥有 onDraw 调用发生的频率较低 - 理想情况下仅当 MapView 更改范围时?我尝试在 onDraw 中检查 MapView 是否具有与上次 onDraw 调用中相同的纬度/经度跨度,并且仅绘制如果两者不同。这导致 OverlayItems 仅在地图平移或缩放时出现。

关于提高性能有什么想法吗?

I have a class:

public class WaypointOverlay extends ItemizedOverlay<OverlayItem>

It overrides the draw() method of the ItemizedOverlay.
In my Activity, I have a map with many overlay items as well as a list. I noticed from traceviewer output and logcat that MapView.onDraw() was being called many times even when the map goes untouched. This resulted in a really unresponsive list and map (when I have my WaypointOverlay class simply return from these onDraw calls, everything performs well)

How can I have the onDraw calls happen less frequently - ideally only when the MapView changes span? I tried, in onDraw, checking if the MapView has the same lat/lon span as it did in the last onDraw call, and only drawing if the two are different. This caused the OverlayItems to only appear when the map was panning or zooming.

Any ideas on improving performance?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

紫南 2024-11-16 02:34:18

我想我可能已经解决了这个问题(至少对于我来说)。在我的应用程序中,用户可以离开地图然后返回到地图,所有这些都在同一个活动中进行。每次用户返回地图时,我都会重新添加我创建的所有叠加层。这意味着地图上有太多的叠加层 - 我看不到它们,因为它们重叠了。调用 MapView.getOverlays().clear() 使地图和列表的性能显着提高。

I think I may have solved this problem (for my case, at least). In my app, the user can navigate away from the map and then return to it, all in the same activity. Every time the user returned to the map, I re-added all the overlays I had created. This meant that way too many overlays were on the map - I couldn't see them because they overlapped. Calling MapView.getOverlays().clear() has made the map and list perform substantially better.

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