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