我有以下代码来获取我的应用程序中的用户位置:
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);
}