【发布时间】:2018-01-27 06:26:46
【问题描述】:
我有两个类都符合MKAnnotation,我想知道,当用户缩小并显示所有注释时,有没有办法强制MapKit 不聚集注释?
【问题讨论】:
标签: ios swift mapkit mkannotation
我有两个类都符合MKAnnotation,我想知道,当用户缩小并显示所有注释时,有没有办法强制MapKit 不聚集注释?
【问题讨论】:
标签: ios swift mapkit mkannotation
上述解决方案对我不起作用,但此解决方案有效:
final class CarPinMarkerView: MKMarkerAnnotationView {
override var annotation: MKAnnotation? {
willSet {
displayPriority = MKFeatureDisplayPriority.required
}
}
}
希望对你有帮助。
【讨论】:
将 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
}
}
}
}
【讨论】:
clusteringIdentifier 设置为 nil,但缩小时标记仍然消失。