How to get location name using mapkit in iphone?

人盡茶涼 提交于 2019-12-06 04:36:09

In iOS 5+ use CLGeocoder and its reverseGeocodeLocation:completionHandler: method.

In your case, you're probably most interested in the areasOfInterest property.

Example:

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 );
    }
}];
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!