//
苹果自带编码
CLGeocoder
*geocoder = [[CLGeocoder
alloc] init];
// 通过地址获取经纬度
[geocoder geocodeAddressString:@"呼和浩特"
completionHandler:^(NSArray
*placemarks, NSError *error) {
if (placemarks.count>0) {
CLPlacemark *placemark = [placemarks
objectAtIndex:0];
NSLog(@"%@",placemark.location);
}
}];
// 通过经纬度获取地址
[geocoder reverseGeocodeLocation:location
completionHandler:^(NSArray
*array, NSError *error)
{
if
(array.count > 0)
{
// CLPlacemark类里的属性包含了详细的地址信息
CLPlacemark *placemark = [array
objectAtIndex:0];
NSString *city =
placemark.locality;
NSLog(@"%@",city);
}
else
if (error == nil && [array count] == 0)
{
NSLog(@"No results were returned.");
}
else
if (error != nil)
{
NSLog(@"An error occurred = %@", error);
}
}];