3
我有下面的代碼讓我的應用程序的用戶位置:緯度,經度從mapView.userLocation
mapView.showsUserLocation=TRUE;
[email protected]"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);
}
這裏是一個[類似的問題](http://stackoverflow.com/questions/1449486/iphone-current-user-location-coordinates-showing-as-0-0)。 – greg 2010-02-24 14:00:13