我有两个都符合MKAnnotation
的类,我想知道,有没有一种方法可以强制MapKit
在用户缩小并显示所有注释时不将注释聚类?
最佳答案
将MKAnnotation的clusteringIdentifier
设置为nil。
例如
class BikeView: MKMarkerAnnotationView {
override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override var annotation: MKAnnotation? {
willSet {
if let bike = newValue as? Bike {
clusteringIdentifier = nil
}
}
}
}