Skip to content

Instantly share code, notes, and snippets.

@UjwalManjunath
Created July 29, 2013 23:38
Show Gist options
  • Save UjwalManjunath/6108872 to your computer and use it in GitHub Desktop.
Save UjwalManjunath/6108872 to your computer and use it in GitHub Desktop.
Converting Longitude Lattitude to Street Address (IOS/ OBJECTIVE C)
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations{
CLLocation *currentLocation = [locations lastObject];
if (currentLocation != nil) {
NSLog(@" Longitude: %@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]);
NSLog(@"Latitude: %@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]);
}
[self.locationManager stopUpdatingLocation];
NSLog(@"Resolving the Address");
self.geocoder = [[CLGeocoder alloc]init];
[self.geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
if(error == nil && [placemarks count]>0){
self.placemark = [placemarks lastObject];
NSLog(@"Address : %@ %@ \n %@ %@ \n %@ \n %@",self.placemark.subThoroughfare,self.placemark.thoroughfare,self.placemark.postalCode,self.placemark.locality
,self.placemark.administrativeArea,self.placemark.country);
}
else {
NSLog(@"%@", error.debugDescription);
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment