Closed staticdreams closed 5 years ago
This seem to be happening only when a cluster "has been used" to reveal underlined annotations and becomes hidden when it's time to put them back in.
I have followed the Swift example and my code is largely based on in except for the part where I apply dynamic text on the clusters (cluster count)
Here's my func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { if (annotation is MKUserLocation) { return nil } guard let cluster = annotation as? CKCluster else { return nil } if cluster.count > 1 { let cView = mapView.dequeueReusableAnnotationView(withIdentifier: ClusterAnnotationIdentifier) ?? CKClusterView(annotation: annotation, reuseIdentifier: ClusterAnnotationIdentifier, count: cluster.count) return cView } return mapView.dequeueReusableAnnotationView(withIdentifier: PointAnnotationIdentifier) ?? CKAnnotationView(annotation: annotation, reuseIdentifier: PointAnnotationIdentifier) }
And annotations code:
class CKAnnotationView: MKAnnotationView { override init(annotation: MKAnnotation?, reuseIdentifier: String?) { super.init(annotation: annotation, reuseIdentifier: reuseIdentifier) canShowCallout = true isDraggable = false image = UIImage(named: "blue-marker") } required init?(coder aDecoder: NSCoder) { fatalError("Not implemented") } } class CKClusterView: MKAnnotationView { convenience init(annotation: MKAnnotation?, reuseIdentifier: String?, count: UInt) { self.init(annotation: annotation, reuseIdentifier: reuseIdentifier) let icon = "\(count)".to(image: UIImage(named: "cluster-marker")!, atPoint: CGPoint(x: 0, y: 8)) image = icon } override init(annotation: MKAnnotation?, reuseIdentifier: String?) { super.init(annotation: annotation, reuseIdentifier: reuseIdentifier) } override func prepareForReuse() { super.prepareForReuse() image = nil } required init?(coder aDecoder: NSCoder) { fatalError("Not implemented") } } class ParkingPointAnnotation: NSObject, MKAnnotation { var coordinate: CLLocationCoordinate2D var title: String? var subtitle: String? init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String) { self.coordinate = coordinate self.title = title self.subtitle = subtitle } }
Any suggestion where I can take a look in order to debug this?
Hello,
Have you been able to resolve this, because I am seeing the same thing on my side?
@franck-nadeau I switched to Mapbox instead and it seemed to work fine
This seem to be happening only when a cluster "has been used" to reveal underlined annotations and becomes hidden when it's time to put them back in.
I have followed the Swift example and my code is largely based on in except for the part where I apply dynamic text on the clusters (cluster count)
Here's my
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?
:And annotations code:
Any suggestion where I can take a look in order to debug this?