Широта, долгота из mapView.userLocation

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

person Marco    schedule 24.02.2010    source источник
comment
Вот аналогичный вопрос.   -  person greg    schedule 24.02.2010


Ответы (1)


Вот что у меня сработало.

yourMapView.userLocation.location.coordinate.latitude;
yourMapView.userLocation.location.coordinate.longitude;
person Danny    schedule 05.02.2013