我有以下代码可以在我的应用程序上获取 userLocation:
mapView.showsUserLocation=TRUE;
mapView.userLocation.title=@"Aktuelle Position";
那是在viewDidLoad();
但是我怎样才能从userLocation
下面的方法中得到纬度和经度呢?
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
Koordinate *user = mapView.userLocation;
Koordinate *cord1 = [eventPoints objectAtIndex:2];
CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:cord1.latitude longitude:cord1.longtitude];
Koordinate *cord2 = [eventPoints objectAtIndex:3];
CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:cord2.latitude longitude:cord2.longtitude];
double distance = [loc1 getDistanceFrom:loc2] / 1000;
NSLog(@"Distanz:", distance);
}