I want to get the Location name from the Coordinate value in MapKit for iPhone I want to get the Location name from the Coordinate value in MapKit for iPhone xcode xcode

I want to get the Location name from the Coordinate value in MapKit for iPhone


The Below code shall work in ios5 and above

 CLGeocoder *ceo = [[CLGeocoder alloc]init]; CLLocation *loc = [[CLLocation alloc]initWithLatitude:32.00 longitude:21.322]; //insert your coordinates[ceo reverseGeocodeLocation:loc          completionHandler:^(NSArray *placemarks, NSError *error) {              CLPlacemark *placemark = [placemarks objectAtIndex:0];              if (placemark) {                  NSLog(@"placemark %@",placemark);                  //String to hold address                  NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];                  NSLog(@"addressDictionary %@", placemark.addressDictionary);                  NSLog(@"placemark %@",placemark.region);                  NSLog(@"placemark %@",placemark.country);  // Give Country Name                  NSLog(@"placemark %@",placemark.locality); // Extract the city name                  NSLog(@"location %@",placemark.name);                  NSLog(@"location %@",placemark.ocean);                  NSLog(@"location %@",placemark.postalCode);                  NSLog(@"location %@",placemark.subLocality);                  NSLog(@"location %@",placemark.location);                  //Print the location to console                  NSLog(@"I am currently at %@",locatedAt);              }              else {                  NSLog(@"Could not locate");              }          } ];


-(NSString *)getAddressFromLatLon:(double)pdblLatitude withLongitude:(double)pdblLongitude{  NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%f,%f&output=csv",pdblLatitude, pdblLongitude];  NSError* error;  NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];   // NSLog(@"%@",locationString);  locationString = [locationString stringByReplacingOccurrencesOfString:@"\"" withString:@""];  return [locationString substringFromIndex:6];}


Use this method

CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation: zoomLocation completionHandler:^(NSArray* placemarks, NSError* error){} ];