У меня есть следующий код для получения 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);
}