We've got some areas of dense annotations/clusters on our map, but when the user is zoomed all the way in, the clusters spend several seconds reorganizing, even after the user has tapped one.
This was not a problem when we were using MKMapView without SwiftUI, so the issue might be related to Views updating. I'm trying to give clusters and their member annotations a similar clusteringIdentifier when zoomed all the way in, but that causes the exception:
MKAnnotationView instances for cluster annotations cannot use a different clusteringIdentifier than its annotation.
I've tried a few variations of this:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
...
if let cluster = annotation as? MKClusterAnnotation {
let id = UUID().uuidString
mapView.view(for: annotation)?.clusteringIdentifier = id
view = ClusterAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.clusteringIdentifier = id
for anno in cluster.memberAnnotations {
if mapView.annotations.contains(where: { anno === $0 }) {
mapView.view(for: anno)?.clusteringIdentifier = id
}
}
}
}
Any advice on getting clusters to stop reorganizing while not zooming in or out would be appreciated.