I have a mapView which I place Annotations on, however when I zoom out they disappear. I've looked at other tutorials that show that you have to put display priority as .required, but that still doesn't work for me.
Here's my code
extension MapVC: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard let _annotation = annotation as? MyAnnotation else {return nil}
let identifier = "Annotation"
var view: MKMarkerAnnotationView
if let dequeuedView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKMarkerAnnotationView {
dequeuedView.annotation = annotation
dequeuedView.titleVisibility = .visible
dequeuedView.displayPriority = .required
view = dequeuedView
}
else
{
view = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
view.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
view.displayPriority = .required
view.titleVisibility = .visible
}
return nil
}
}