各位客官请笑纳。
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(^{
//快刷数据啦,后生仔~
});
}
}];
网友评论