Obtain the place name according to latitude and longitude, obtain latitude and longitude according to place name

Source: Internet
Author: User

1.Get the place name according to latitude and longitude [OBJC] view plaincopy on code to view the snippet derivation to my code slice clgeocoder *clgeocoder = [[Clgeocoder alloc] init]; [Clgeocoder reversegeocodelocation:newlocation Completionhandler: ^ (Nsarray*placemarks,Nserror*error) { for(Clplacemark *placemark in Placemarks) {nsdictionary*addressdic=placemark. Addressdictionary;NSString*state=[addressdic objectforkey:@"State"];NSString*city=[addressdic objectforkey:@"City"];NSString*sublocality=[addressdic objectforkey:@"Sublocality"];NSString*street=[addressdic objectforkey:@"Street"]; [ SelfStoplocation];           [_choosecitybtn settitle:city Forstate:uicontrolstatenormal];       [_activityindicator stopanimating]; }   }];
2.Get latitude and longitude according to the place name [OBJC] View plaincopy on code to see a snippet derived from my Code slice * * *//This address is uploaded according to your needs--------------***NSString*oreillyaddress = @"1005 Gravenstein Highway North, Sebastopol, CA 95472, USA";  Clgeocoder *mygeocoder = [[Clgeocoder alloc] init]; [Mygeocoder geocodeaddressstring:oreillyaddress completionhandler:^ (Nsarray*placemarks,Nserror*error) {if([Placemarks Count] >0&& Error = =Nil) {NSLog(@"Found%lu placemark (s).", (unsigned Long) [Placemarks Count]); Clplacemark *firstplacemark = [Placemarks objectatindex:0];NSLog(@"longitude =%f", Firstplacemark. location. Coordinate. Longitude);NSLog(@"Latitude =%f", Firstplacemark. location. Coordinate. Latitude); }Else if([placemarks count] = =0&& Error = =Nil) {NSLog(@"Found no placemarks."); }Else if(Error! =Nil) {NSLog(@"An error occurred =%@", error); }  }];

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Obtain the place name according to latitude and longitude, obtain latitude and longitude according to place name

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.