【发布时间】:2019-09-12 05:25:42
【问题描述】:
我在我的项目中添加了带有注释的集群,它工作正常,但设置限制有问题。
请在此处查看下图,对 6 个注释进行了分组,但我想设置应该从 20 开始分组的聚类限制(所以永远不要看到其中一个数字为 19 或更低)
func mapView(_ mapView: MKMapView, clusterAnnotationForMemberAnnotations memberAnnotations: [MKAnnotation]) -> MKClusterAnnotation {
return MKClusterAnnotation(memberAnnotations: memberAnnotations)
}
我也试过这个,但不适合我。
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let groupedpin = annotation as! MKClusterAnnotation
if groupedpin.memberAnnotations.count >= 20 { //<— Not working
let view = PlaceClusterAnnotationView.annotationView()
view._count = groupedpin.memberAnnotations.count.description
return view
}
return MKAnnotationView()
}
【问题讨论】:
-
非常好的问题。对此有什么好的解决方案吗?
标签: swift xcode mapkit mkannotation mkclusterannotation