简体   繁体   English

如果附近有太多Map Pins,则MKMapView会聚类

[英]MKMapView clustering if too many Map Pins nearby

I'm wondering if any of you knows a method (library, category, etc.) to cluster iOS MapAnnotations if there are many of them at the same location (eg 4 pieces in about 10m). 我想知道是否有人知道一个方法(库,类别等)来集群iOS MapAnnotations,如果它们在同一位置有很多(例如,大约10米的4件)。

It doesn't matter to zoom in because they are still overlapping. 放大并不重要,因为它们仍然重叠。 I've already tried https://github.com/applidium/ADClusterMapView (and sombe other libs) but all of them are made for showing clusters in zoom-out-scenarios. 我已经尝试过https://github.com/applidium/ADClusterMapView (和sombe其他libs),但所有这些都是为了在缩小场景中显示集群而制作的。 None of them really respect the distance between annotations when zoomed in. 放大时,他们都没有真正尊重注释之间的距离。

I'm working on an app with an offline-db so a server-side solution is not an option. 我正在开发一个带有offline-db的应用程序,因此无法选择服务器端解决方案。

thank you for your help! 谢谢您的帮助!

You don't need 3rd party framework's anymore. 你不再需要第三方框架了。 iOS 11 has native clustering support. iOS 11具有本机群集支持。

You need to implement mapView:clusterAnnotationForMemberAnnotations: method. 您需要实现mapView:clusterAnnotationForMemberAnnotations:方法。

Get more details in the Apple example: https://developer.apple.com/sample-code/wwdc/2017/MapKit-Sample.zip 在Apple示例中获取更多详细信息: https//developer.apple.com/sample-code/wwdc/2017/MapKit-Sample.zip

您应该查看CCHMapClusterController项目,看起来完全像您正在寻找的东西。

One alternative is the MapBox iOS SDK, which is an open source (BSD) library replicating MapKit behavior. 另一种选择是MapBox iOS SDK,它是一个复制MapKit行为的开源(BSD)库。 It does both annotation clustering and offline map layers. 它同时执行注释聚类和离线地图图层。

http://mapbox.com/mobile http://mapbox.com/mobile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM