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 zooms out and display all annotations?
Asked
Active
Viewed 2,528 times
5

kalpesh satasiya
- 799
- 8
- 18

dinosaysrawr
- 348
- 2
- 15
2 Answers
7
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.

Tung Fam
- 7,899
- 4
- 56
- 63
-
1This should be the accepted answer. You solved my problem! – Colby Hill Aug 11 '20 at 22:50
3
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
}
}
}
}

Kosuke Ogawa
- 7,383
- 3
- 31
- 52
-
1I've set the `clusteringIdentifier` to nil but still markers disappear when zoomed out. – Rezwan Feb 11 '18 at 06:57
-
I have posted a question [here](https://stackoverflow.com/questions/48685469/disabling-mkmapview-clustering-annotations-automatically?noredirect=1#comment84370793_48685469). could you please take a look? thank you – Rezwan Feb 11 '18 at 07:11
-
This seems to work if you subclass MKPinAnnotationView but not MKMarkerAnnotationView. Is there anyway to disable clustering without losing the functionality of the markerview? – David May 07 '18 at 17:29