Find visible cluster annotations (MKClusterAnnotation)

Hi!

I’m currently developing an app with MapKit on iOS 11 and I’m using the new annotation clustering feature.


At some point I need to find all the cluster annotations currently visible on the map.


I tried iterating trough the mapView.annotations array and looking for annotations that are MKClusterAnnotation. The problem is that it seems that the annotations array does not only contain the currently visible clusters but also other clusters, probably the clusters created in the past. For this reason I cannot know which clusters are currently visible and which are not.


You can reproduce this by adding some annotations on a map, zoom out the map so that the annotations start to group together and then zoom in the map so that the annotations become ungrouped until no more clusters are visible on the map. If you look in the map annotations array you will still find many cluster annotations.


Someone know how I can get only the list of the cluster objects (MKClusterAnnotation) that are currently visible on the map?


Thank you


Alan

Hello,

I have the same need on MapKitJS. I would like to retrieve all visible cluster on the Map but the attribute visible of annotation is never updated.

Thank you

Gabriel
Find visible cluster annotations (MKClusterAnnotation)
 
 
Q