Closed MaeseppTarvo closed 7 years ago
You can manage the cluster UI in the mapview's data source method.
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let cluster = annotation as? CKCluster {
// Return an annotation view that show the cluster count.
}
}
func mapView(_ mapView: GMSMapView, markerFor cluster: CKCluster) -> GMSMarker {
let marker = GMSMarker(position: cluster.coordinate)
marker.iconView = // Set a view that show the cluster count.
return marker;
}
@maxep I created simple UILabel
and assigned it to the iconView
but the count is totally wrong for some reason. Is thecluster.count
right?
@MaeseppTarvo yes you can use the count
property, I'm not seeing a wrong value on my side.
@MaeseppTarvo I tried adding a label as a subview to the annotationView of the example project and I was experiencing the same issue: the label was off by a lot (and it persisted even when the annotation wasn't a cluster).
If you disable the annotation reuse it works though.
Did you properly clean the count label of the reused view? whether in the prepareForReuse
of the annotation view subclass, or in the data source method mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation)
Hey! How should you add the count to cluster item?