1

我正在開發一個iPhone應用程序,我在工具欄上提供了Pin Annotation按鈕。當用戶點擊按鈕時,引腳將落在地圖視圖的中心。現在,我希望該用戶移動該針腳並將其放置在所需的位置,我將獲得該點的經度和緯度。那麼我如何用我的地圖視圖定義所有這些事件?那是怎麼回事?我得到這個代碼添加註釋。如何獲得點的經度和緯度?

- (void)addPinAnnotation:(id)sender { 
UICRouteAnnotation *pinAnnotation = [[[UICRouteAnnotation alloc] initWithCoordinate:[routeMapView centerCoordinate] 
                       title:nil 
                    annotationType:UICRouteAnnotationTypeWayPoint] autorelease]; 
[routeMapView addAnnotation:pinAnnotation]; 

}

如何得到該點的緯度和經度?

在此先感謝....

回答

1
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 

    // Add annotation to map 
    MKCoordinateRegion reg; 
    CLLocationCoordinate2D location = newLocation.coordinate ; 
    reg.center = location; 
    MKCoordinateSpan span; 
    span.latitudeDelta = 1.5; 
    span.longitudeDelta = 1.5; 
    reg.span = span; 
    reg.center=newLocation.coordinate; 
    [self.mapView setRegion:reg animated:TRUE]; 
    annotation = [[myAnnotation alloc] initWithCoordinate:newLocation.coordinate title:@"Click > to set or drag to move"]; 
    [self.mapView addAnnotation:annotation]; 
    [self.mapView selectAnnotation:annotation animated:YES]; 
    [manager stopUpdatingLocation]; 
    [loading stopAnimating]; 
}