hulab / ClusterKit

An iOS map clustering framework targeting MapKit, Google Maps and Mapbox.
MIT License
512 stars 86 forks source link

How to: display the number of objects in the cluster on the map #46

Closed Belzik closed 3 years ago

Belzik commented 6 years ago

Hey, guys. I would like to thank you for this library. But I have a question. Is it possible to display the number of objects in the cluster next to the cluster icon or inside the cluster icon? I use Mapbox.

dvertovsek commented 6 years ago

@Belzik This stackoverflow answer helped me with the same problem :)

You can find the number of annotations in a cluster inside the method func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?

using:

if let ckCluster = annotation as? CKCluster {
          annotationView.image = yourImage.draw("\(ckCluster.count)")
}
ulaserdegor commented 5 years ago

@Belzik This stackoverflow answer helped me with the same problem :)

You can find the number of annotations in a cluster inside the method func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?

using:

if let ckCluster = annotation as? CKCluster {
          annotationView.image = yourImage.draw("\(ckCluster.count)")
}

give wrong numbers