S. Doe
S. Doe

Reputation: 163

Check Which Annotation Callout is Opening

I'm working on a project where I need to find the estimated travel time from the user location to a certain MKAnnotation. I would like to be able to see which annotation the user has clicked on so I can generate the ETA and display it on the annotationCalloutView using the "viewFor annotation" function.

This ETA cannot be calculated using a custom MKAnnotation class due throttling from Apple if done in this way: HERE So it must be done while the annotation callout is opening.

Upvotes: 1

Views: 64

Answers (1)

Rashwan L
Rashwan L

Reputation: 38833

You have the mapView delegate method:

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {

}

You have the parameter view which is the clicked MKAnnotationView and from that parameter you can access your annotation.

Upvotes: 1

Related Questions