简体   繁体   中英

How to get current location of MapView in NSLog?

I am able to get the longitude and altitude of user's current location but, not the name of location . I used userLocation property as below:

NSLog(@"Current location=%@",mapView.userLocation);

but, it gives me output as Current location=<MKUserLocation: 0x1f59e8c0>

I want to get the string value of that location instead of 0x1f59e8c0. How to do this?

NSLog(@"Current location %@",mapView.userLocation.title); 

PS还有更多属性字幕

Starting at the MKMapView documentation: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

You can follow the chain down to find the longitude is part of a CLLocationCoordinate2D (and is a double) http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html#//apple_ref/doc/c_ref/CLLocationCoordinate2D

NSLog(@"Current longitude = %f",mapView.userLocation.location.coordinate.longitude); 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM