2013-02-13 103 views
0

在我的應用程序中,當我點擊地圖並知道此點的經度和緯度時,我需要先註釋註釋,然後在經度和緯度上都只打印一個標籤,告訴我該怎麼做?如何在xcode中查找mapview的經度和緯度?

我試過下面的代碼,但沒有幫助。

- (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; 
} 
+0

的http://計算器.com/questions/4806628/is-there-any-way-to-the-lat-long-of-mkmapview-of-touch-position-iphone-sdk – rptwsthi 2013-02-13 07:34:22

回答

1

從這裏就可以得到lat和長註釋

的用於獲取緯度使用這種

[[[view annotation] coordinate].latitude 

和經度這樣

[[[view annotation] coordinate]. longitude 
+0

bu如何把註釋.... ?? – adevani11 2013-02-13 08:43:27