作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我编制了一份包含经纬度信息的位置列表。我可以检查什么是根据我当前的位置过滤和填充表格和 map View 中“最近”地理位置列表的最佳方法吗? (或用户输入的目的地)。也可以指出我感兴趣的半径是多少?例如仅选择距我所在位置 5 公里以内的所有最近的书店等
感谢您对此的建议
郑和
最佳答案
也许我遗漏了什么,但为什么不直接将您的位置添加到 mapView,并将 map 居中放置在用户的当前位置或他们想要的任何位置? MapKit 会为你做所有的计算,并且只显示靠近中心的那些。用户可以通过放大和缩小来设置自己的半径。 MapKit 正是为此目的进行了高度优化,这就是您如何实时查看“针雨”。
更新:您也可以采用另一种方式:一旦您在 map 上有了注释,您就可以在 map 上查询可见区域中的那些注释:
- (NSSet *)annotationsInMapRect:(MKMapRect)mapRect
来自文档:
This method offers a fast way to retrieve the annotation objects in a particular portion of the map. This method is much faster than doing a linear search of the objects in the annotations property yourself.
关于objective-c - Objective-C : How to list set of locations with the nearest geolocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5907311/
我是一名优秀的程序员,十分优秀!