iOS 经纬度转化成文本地理位置

各位客官请笑纳。


CLGeocoder *clGeoCoder = [[CLGeocoder alloc] init]; CLLocation *location = [[CLLocation alloc] initWithLatitude:self.y longitude:self.x]; 

 BBWeakObj(self) // 反地理编码(经纬度---地址)

 [clGeoCoder reverseGeocodeLocation:location completionHandler:^(NSArray* _Nullable placemarks, NSError * _Nullable error) {

BBStrongObj(self)

if(error == nil)

{

CLPlacemark *pl = [placemarks firstObject];

//挑出你最喜爱的字段

self.address = [NSString stringWithFormat:@"%@%@",pl.locality,pl.name];

}else

{

self.address = nil;

}

if (self.address) {

MAIN(^{

//快刷数据啦,后生仔~

});

}

}];

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容