Get the latitude and longitude of iOS and get a detailed address by reverse geocoding

Source: Internet
Author: User
Tags reverse geocoding

1_locationmanager =[[Cllocationmanager alloc] init];2 3     //the desired longitude4 5_locationmanager.desiredaccuracy =kcllocationaccuracybest;6 7     //change about 100 m update once8 9_locationmanager.distancefilter = -;Ten  One     //Certified Nslocationalwaysusagedescription A  -     if([[Uidevice Currentdevice] Systemversion].doublevalue >8.0) {//if iOS is 8.0 or later -  the         if([_locationmanager respondstoselector: @selector (requestalwaysauthorization)]) {//the Requestalwaysauthorization method is available in the Location management object -  -             //Run -  + [_locationmanager requestalwaysauthorization]; -  +         } A  at     } -  -_locationmanager.Delegate=Self ; -  - [_locationmanager startupdatinglocation]; -  in   -  to //get latitude and longitude and detailed address +  -- (void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (nsarray<cllocation *> *) Locations { the  *      $ Panax NotoginsengCllocation *location =[Locations Lastobject]; -  theNSLog (@"Latitude = = =%g Longitude = = =%g", Location.coordinate.latitude, location.coordinate.longitude); +  A      the  +     //Reverse geocoding -  $Clgeocoder *clgeocoder =[[Clgeocoder alloc] init]; $  -Cllocation *CL =[[Cllocation alloc] InitWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude]; -  the[Clgeocoder reversegeocodelocation:cl Completionhandler: ^ (Nsarray *placemarks,nserror *error) { - Wuyi          for(Clplacemark *placemarkinchplacemarks) { the  -              Wu  -Nsdictionary *addressdic =placemark.addressdictionary; About  $              -  -NSString *state=[addressdic Objectforkey:@" State"]; -  ANSString *city=[addressdic Objectforkey:@" City"]; +  theNSString *sublocality=[addressdic Objectforkey:@"sublocality"]; -  $NSString *street=[addressdic Objectforkey:@"Street"]; the  the              the  theNSLog (@"City ====%@%@%@%@", state, City, Sublocality, street); -  in [_locationmanager stopupdatinglocation]; the  the         } About  the     }]; the  the } +  -  

Get the latitude and longitude of iOS and get a detailed address by reverse geocoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.