更改 MapKit 视图内的注释
我有很多注释需要在 Mapkit 视图中管理。
规则是: 1 - 仅当mapView.region.span.longitudeDelta高于0.042时显示注释 2 - 仅在可见区域内显示注释。 3-当注释出现在可见区域时将其删除...
我该怎么做...分享您的经验...
谢谢
I have a lot of annotations to manage inside the mapkit view.
The rules are :
1 -only show annotations when the mapView.region.span.longitudeDelta is above 0.042
2 -only show annotations inside the visible area.
3- remove the annotations when they comes out the visible area...
How I can do that ... Share your experience...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要一些东西。一种是在数据库中搜索地图视图中具有纬度和经度的图钉。这称为边界框。接下来是当注释移出地图的可见矩形时删除注释。每次移动地图时,您都必须重新计算哪些图钉在盒子里,哪些图钉在盒子外面但仍在地图上。
我可以给你的一个提示是将地图的可见矩形划分为正方形(可能是 17 x 23 的正方形或 20 x 20 的正方形),并计算出图钉是否进入该正方形。如果是,则将该方块标记为已填充,如果另一个图钉想要进入该方块,请不要让它进入。这将允许您过滤引脚,这样屏幕上一次不会出现太多引脚。
这不是一个简单的问题,但是如果您进行一些搜索,您就会找到解决方法。此 Google 地图集群标记代码可能会有所帮助。
You need a few things. One is to search your database for the pins with latitudes and longitudes inside the map's view. This is called a bounding box. The next is to remove the annotations when they move outside the visible rect of the map. Each time the map is moved, you'll have to recalculate what pins are in the box and what pins are outside but still on the map.
One hint I can give you is to divide the visible rect of the map into squares (maybe 17 x 23 squares of 20 x 20) and figure out if a pin goes into that square. If it does, mark that square as filled, and if another pin wants to go into that square, don't let it. This will allow you to filter the pins so there aren't too many on screen at one time.
It's not an easy problem, but if you do some search around you'll find your way through it. This cluster marker code for Google Maps might help.