I am using following code for get address from current latitude and longitude, But I am not able to get proper response
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
current_latitude=newLocation.coordinate.latitude;
current_longitude=newLocation.coordinate.longitude;
CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
if(placemarks && placemarks.count > 0)
{
CLPlacemark *placemark= [placemarks objectAtIndex:0];
NSString * address = [NSString stringWithFormat:@"%@ %@,%@ %@", [placemark subThoroughfare],[placemark thoroughfare],[placemark locality], [placemark administrativeArea]];
UIAlertView *art = [[UIAlertView alloc] initWithTitle:address message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[art show];
[art release];
NSLog(@"%@",address);
}
}];
}
CLLocation
has poor coverage at the moment; see this document . It's possible you're trying to geocode a location from a poorly covered area.
If that's the case, there are other geocoders, such as Google's Geocoder (which requires you to display the results on a map).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.