Hi,
I am currently displaying multiple custom Annotations on a map and when i went up to about 250 the map starts lagging.
When i pan across the map: no problem. But as soon as the user stops panning the map repositions itself somewhere completely else.
I reset the annotations and removed
annotationView!.image = UIImage(named: "pin")
and everything was fine (off course the image was the tipical MapKit-logo but everything else worked out)
I am using a MKPointAnnotation class to define specific properties of my Annotations and this function to specify:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView {
guard let annot = annotation as? customAnnotation else {return nil}
if annotation is MKUserLocation { return nil }
let annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "customAnnotation")
mapView.addAnnotation(annot)
annotationView.image = UIImage(named: "pin")
annotationView.canShowCallout = true
annotationView.clusteringIdentifier = String(describing: ClusterAnnotationView.self)
//here just some Buttons inside the Callout
return annotationView as MKAnnotationView
I am also using two methods to handle the amount of Annotation:
One of them deletes all annotations not shown on the screen and the other one clusters them ( -> clusteringIdentifier)
Thanks for your help,
Gus