I imagine its pretty simple, but I wont find it.
I want to show the longitude und latitude of the current user position in two textfields. One for each value.
But it defenatly wont work.
I thought it will be easy with one of the following values... But there are so many possibilitys of lon and lat...
mapView.userLocation.coordinate.latitude
mapView.userLocation.coordinate.latitude
mapView.userLocation.location.coordinate.latitude
mapView.userLocation.location.coordinate.longitude
Does anyone know which combination I need to take to simply get the long and lat value?
Thank you in advance from germany
The userLocation may not yet be available in viewDidLoad if that is also where the map view itself is being initialized.
A better place is in the didUpdateUserLocation
delegate method:
- (void)mapView:(MKMapView *)mapView
didUpdateUserLocation:(MKUserLocation *)userLocation
{
NSLog(@"userLocation = %f,%f", mapView.userLocation.coordinate.latitude,
mapView.userLocation.coordinate.longitude);
}
Also make sure that:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.