在 iPhone 的 MapKit 中显示 POI 的最佳实践?

发布于 2024-08-28 01:50:22 字数 320 浏览 2 评论 0原文

假设我有一个 POI 数据库及其各自的坐标(经度和纬度)。将 POI 显示为用户当前位置周围注释的“标准”方式是什么?详细说明:

  • 给定缩放级别,我想我必须在数据库中搜索到当前位置距离 < 的所有 POI。一定的阈值,然后为它们创建注释。或者有什么更聪明的方法吗?
  • 如果用户放大/缩小,移动地图......我需要再次重做整个事情?
  • 看来 MapKit 有一种缓存/重用注释的机制。我是否应该立即创建很多它们并让 MapKit 决定当可见区域发生变化时渲染什么?我想这会让过渡更平滑,但也会消耗更多内存。您对此有什么经验?

谢谢。

Assuming I have a database of POI with their respective coordinates (longitude & latitude). What would be the "standard" way to display the POI as annotations around the user's current location? To elaborate:

  • Given a zoom level, I guess I have to search through the database for all POI whose distance to the current location < a certain threshold, then create annotations for them. Or is there any smarter way?
  • If the user zooms in/out, moves the map... I will need to redo the whole thing again?
  • It seems that MapKit has a mechanism to cache/reuse annotations. Should I create a lot of them right away and let MapKit decides what to render when the visible region changes? I guess this would make the transition smoother, but also consumes more memory. What is your experience with this?

Thanks.

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

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

发布评论

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

评论(1

痴情换悲伤 2024-09-04 01:50:22

实际上,依赖当前位置和 POI 之间的距离并不是正确的方法:评估距离需要时间,您最好只依赖地图显示的区域(属性 region)并检查您的哪些 POI 包含在该区域中。

放大/缩小时,区域会发生变化,因此您可能必须重做相同的操作。

在这里查看我的答案:
MKMapView加载所有注释立即查看(包括当前矩形之外的视图)

这个人正在尝试使用注释缓存,我的答案可能会对您的情况有所帮助。

要检查您的 POI 是否是显示的区域,我发布了一段可能有帮助的代码:
iPhone 开发 - 是 Pin 注释吗?可视地图区域

Actually, relying on the distance between the current location and the POIs is not the right approach : evaluating distances takes time, you'd better just rely on the region displayed by your map (property region) and check which of your POIs are contained in this region.

When zooming in / out, the region changes, so you may have to redo the same.

See my answer here :
MKMapView loading all annotation views at once (including those that are outside the current rect)

This guy is trying to use the caching of annotations and my answer may help you in your case.

To check if your POI is the displayed region, I posted a piece of code that may help here :
iPhone Development - Is Pin Annotation in a viewable Map Region

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