When i do not set a delegate on MKMapView
but add annotations, their images come up as the following:
However if i return a MKAnnotationView
like so:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation.isKind(of: MKUserLocation.self) {
return nil
}
guard annotation is MKPointAnnotation else { return nil }
let identifier = "Annotation"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView!.collisionMode = .circle
annotationView!.canShowCallout = true
} else {
annotationView!.annotation = annotation
}
return annotationView
}
Then the icons come out looking like a vertical pin:
I know i can use a custom image on the MKAnnotationView
. However, i want the default one, except i want it to look like the first rather than the second, but i also want to customise the callout. How can i achieve this?
The first image belongs to an MKMarkerAnnotationView. So ask for that, instead of an MKPinAnnotationView.