我使用以下代码从当前纬度和经度获取地址,但我无法得到正确的回复
- (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);
}
}];
}
答案 0 :(得分:0)
CLLocation
目前报道不佳;见this document。您可能正在尝试从覆盖不良的区域对地理位置进行地理编码。
如果是这种情况,还有其他地理编码器,例如Google's Geocoder(要求您在地图上显示结果)。