Reputation: 415
In my application I need to first pin annotation when ever I click the map and know to longitude and latitude of this point and after this both longitude and latitude I want to print on only one label, tell me how can I do this?
I tried following code, But no help.
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[PlaceMark class]]) {
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [myMapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
return annotationView;
}
return nil;
}
Upvotes: 0
Views: 480
Reputation: 6427
From this you can get the lat and long of annotation
for getting the latitude use this
[[[view annotation] coordinate].latitude
And longitude like this
[[[view annotation] coordinate]. longitude
Upvotes: 1