是否可以强制 MapKit 在没有聚类的情况下显示所有注释?

din*_*awr 4 mapkit mkannotation ios swift

我有两个类都符合MKAnnotation,我想知道,MapKit当用户缩小并显示所有注释时,有没有办法强制不聚集注释?

Tun*_*Fam 6

提到的解决方案对我不起作用,但这个解决方案有效:

final class CarPinMarkerView: MKMarkerAnnotationView {
  override var annotation: MKAnnotation? {
    willSet {
        displayPriority = MKFeatureDisplayPriority.required
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你。


Kos*_*awa 3

将 MKAnnotation 设置clusteringIdentifier为零。

例如

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
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)