1

我正在开发一个 iPhone 应用程序,其中我在工具栏上提供了 Pin Annotation 按钮。当用户单击按钮时,图钉将落在地图视图的中心。现在我希望该用户移动该图钉并将其放置在他们想要的位置,我将获得该点的纬度和经度。那么我如何用我的地图视图定义所有这些事件呢?怎么做?我得到这个添加注释的代码。

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

}

如何获得该点的纬度和经度?

提前致谢....

4

1 回答 1

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];
}
于 2011-08-29T14:03:47.977 回答