我是靠谱客的博主 儒雅豌豆,最近开发中收集的这篇文章主要介绍7.8 Converting Longitude and Latitude to a Meaningful Address,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述



通过经纬度获取地址信息

- (void)viewDidLoad

{

    [superviewDidLoad];

CLLocation *location = [[CLLocationalloc] initWithLatitude:39.904989

                                                     longitude:116.405285];

   self.myGeocoder = [[CLGeocoderalloc] init];

    [self.myGeocoder

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

        if (error == nil && [placemarkscount] > 0){

            CLPlacemark *placemark = [placemarks objectAtIndex:0]; /* We received the results */

            NSLog(@"Country = %@", placemark.country);

            NSLog(@"name = %@", placemark.name);

            NSLog(@"thoroughfare = %@", placemark.thoroughfare);

            NSLog(@"subThoroughfare = %@", placemark.subThoroughfare);

            NSLog(@"locality = %@", placemark.locality);

            NSLog(@"subLocality = %@", placemark.subLocality);

            NSLog(@"administrativeArea = %@", placemark.administrativeArea);

             NSLog(@"subAdministrativeArea = %@", placemark.subAdministrativeArea);

            NSLog(@"postalCode = %@", placemark.postalCode);

            NSLog(@"ISOcountryCode = %@", placemark.ISOcountryCode);

            NSLog(@"inlandWater = %@", placemark.inlandWater);

            NSLog(@"ocean = %@", placemark.ocean);

            NSLog(@"areasOfInterest = %@", placemark.areasOfInterest);

         }

        else if (error ==nil &&

                  [placemarkscount] == 0){

             NSLog(@"No results were returned.");

         }

        else if (error !=nil){

            NSLog(@"An error occurred = %@", error); }

     }];

}



输出:

2014-04-08 14:12:59.756 cookbook[592:c07] Country = China

2014-04-08 14:12:59.758 cookbook[592:c07] name = Danta Coffee

2014-04-08 14:12:59.758 cookbook[592:c07] thoroughfare = Danta Coffee

2014-04-08 14:12:59.758 cookbook[592:c07] subThoroughfare = (null)

2014-04-08 14:12:59.759 cookbook[592:c07] locality = (null)

2014-04-08 14:12:59.759 cookbook[592:c07] subLocality = Dongcheng

2014-04-08 14:12:59.760 cookbook[592:c07] administrativeArea = Beijing

2014-04-08 14:12:59.760 cookbook[592:c07] subAdministrativeArea = (null)

2014-04-08 14:12:59.760 cookbook[592:c07] postalCode = (null)

2014-04-08 14:12:59.760 cookbook[592:c07] ISOcountryCode = CN

2014-04-08 14:12:59.761 cookbook[592:c07] inlandWater = (null)

2014-04-08 14:12:59.761 cookbook[592:c07] ocean = (null)

2014-04-08 14:12:59.761 cookbook[592:c07] areasOfInterest = (null)





如果输入的经纬度是:

CLLocation *location = [[CLLocation alloc] initWithLatitude:24.5

                                                      longitude:118.13];


则输出是:

2014-04-08 14:16:19.442 cookbook[613:c07] Country = China

2014-04-08 14:16:19.443 cookbook[613:c07] name = No. 1389 Xianyue Road

2014-04-08 14:16:19.443 cookbook[613:c07] thoroughfare = Xianyue Road

2014-04-08 14:16:19.444 cookbook[613:c07] subThoroughfare = No. 1389

2014-04-08 14:16:19.444 cookbook[613:c07] locality = Xiamen

2014-04-08 14:16:19.444 cookbook[613:c07] subLocality = Huli

2014-04-08 14:16:19.444 cookbook[613:c07] administrativeArea = Fujian

2014-04-08 14:16:19.445 cookbook[613:c07] subAdministrativeArea = (null)

2014-04-08 14:16:19.445 cookbook[613:c07] postalCode = (null)

2014-04-08 14:16:19.445 cookbook[613:c07] ISOcountryCode = CN

2014-04-08 14:16:19.445 cookbook[613:c07] inlandWater = (null)

2014-04-08 14:16:19.446 cookbook[613:c07] ocean = (null)

2014-04-08 14:16:19.446 cookbook[613:c07] areasOfInterest = (null)



最后

以上就是儒雅豌豆为你收集整理的7.8 Converting Longitude and Latitude to a Meaningful Address的全部内容,希望文章能够帮你解决7.8 Converting Longitude and Latitude to a Meaningful Address所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部