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]; 
}