问题描述
我是iphone开发的新手,现在我在开发开发应用程序时遇到问题,当用户在屏幕上轻按两秒钟并需要获取用户位置名称时,我需要获取坐标(纬度,经度)协调,但我无法获得用户点击的用户位置名称.可以帮我吗?
I am new in iphone development and right now i am facing problem for developing developing an application in which i need to get coordinate(lat, long) when user tapped on screen for two second and also get user location name,i got coordinate but i am unable to get user location name on which user tapped. so kindly help me on that?
推荐答案
在iOS 5+中,使用 CLGeocoder
及其 reverseGeocodeLocation:completionHandler:
方法.
In iOS 5+ use CLGeocoder
and its reverseGeocodeLocation:completionHandler:
method.
以您为例,您可能对areasOfInterest
属性最感兴趣.
In your case, you're probably most interested in the areasOfInterest
property.
示例:
CLGeocoder* gc = [[CLGeocoder alloc] init];
double lat, lon; // get these where you will
[gc reverseGeocodeLocation:[[CLLocation alloc] initWithLatitude:lat longitude:lon] completionHandler:^(NSArray *placemarks, NSError *error) {
for ( CLPlacemark* place in placemarks ) {
if ( place.region )
NSLog( @"%@", place.region );
// throroughfare is street name, subThoroughfare is street number
if ( place.thoroughfare )
NSLog( @"%@ %@", place.subThoroughfare, place.thoroughfare );
for ( NSString* aoi in place.areasOfInterest )
NSLog( @"%@", aoi );
}
}];
这篇关于如何在iPhone中使用Mapkit获取位置名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!