####Converting Longitude and Latitude to a Meaningful Address
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
@interface ()
@property (nonatomic, strong) CLGeocoder *myGeocoder; @end
- (void)viewDidLoad{ [super viewDidLoad]; CLLocation *location = [[CLLocation alloc]initWithLatitude:-38.4112810 longitude:-122.8409780f]; self.myGeocoder = [[CLGeocoder alloc] init]; [self.myGeocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { if (error == nil && placemarks.count > 0){ CLPlacemark *placemark = placemarks[0]; NSLog(@"Country = %@", placemark.country); NSLog(@"Postal Code = %@", placemark.postalCode); NSLog(@"Locality = %@", placemark.locality); } else if (error == nil && placemarks.count == 0){ NSLog(@"没有结果返回."); } else if (error != nil){ NSLog(@"发生一个错误 = %@", error); } }]; }
|
Reference
近期评论