Is it possible to force MapKit to show all annotations without clustering?

后端 未结 2 534
梦如初夏
梦如初夏 2021-01-14 00:27

I have two classes that both conform to MKAnnotation, and I was wondering, is there a way to force MapKit to not cluster the annotation when a user

相关标签:
2条回答
  • 2021-01-14 00:51

    The mentioned solution didn't work for me, but this solution worked:

    final class CarPinMarkerView: MKMarkerAnnotationView {
      override var annotation: MKAnnotation? {
        willSet {
            displayPriority = MKFeatureDisplayPriority.required
        }
      }
    }
    

    Hope it helps.

    0 讨论(0)
  • 2021-01-14 01:00

    Set MKAnnotation's clusteringIdentifier to nil.

    e.g.

    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
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题