John John - 8 months ago 75
iOS Question

Get Latitude and Longitude from Annotation view

How do I get the latitude and longitude of an annotationView placed on my mapView? I need to get it when the rightAccessory gets tapped.


- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
method does return the MKAnnotationView which has a
property to be used. But I want the lat and long. How do I convert the coordinate to lat and long?



coordinate is a CLLocationCoordinate2D, which is a struct containing latitude and longitude.

coordinate is actually a property of MKAnnotation. MKAnnotationView has an MKAnnotation property named annotation.

So, in the method you mentioned you should be able to get to the latitude using [[view annotation] coordinate].latitude and longitude using [[view annotation] coordinate]. longitude.