我目前发现某些注释在缩小时会被 MKMapView 自动隐藏。
我想知道一个注释隐藏了多少个以在用户单击重新组合隐藏的注释的注释时显示此数字,但我不知道如何执行此操作。
提前谢谢你。
最佳答案
这段代码为我做了一切:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: MKMapViewDefaultAnnotationViewReuseIdentifier, for: annotation)
annotationView.clusteringIdentifier = "identifier"
return annotationView
}
来自:Why clusterAnnotationForMemberAnnotations in MKMapView is not called?
感谢@the4Man 的提示
问题仍然存在:如果我不想要当前用户位置,您必须设置 mapView.showsCurrentLocation = false
然后我无法显示用户位置......我完全被困在那里
编辑:通过在 annotation.title = "My Location"时返回 nil 来解决它
希望对你有帮助
关于swift - 如何获取 MKMapView 中隐藏了多少个注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49792541/