从注释视图中获取纬度和经度

0 iphone mkannotation mkannotationview ios

如何获取放置在mapView上的annotationView的纬度和经度?当rightAccessory被点击时,我需要得到它.

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control方法确实返回具有coordinate要使用的属性的MKAnnotationView .但我想要拉特和长.如何将坐标转换为lat和long?

谢谢.

ben*_*ong 8

coordinate是一个CLLocationCoordinate2D包含latitude和的结构longitude.

coordinate实际上是一个属性MKAnnotation.MKAnnotationView有一个MKAnnotation名为的财产annotation.

因此,在您提到的方法中,您应该能够使用[[view annotation] coordinate].latitude和经度使用纬度[[view annotation] coordinate]. longitude.