0

現在の緯度と経度から住所を取得するために次のコードを使用していますが、適切な応答を得ることができません

- (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);
        }
    }];
}
4

1 に答える 1

0

CLLocation現時点ではカバレッジが不十分です。このドキュメントを参照してください。十分にカバーされていない地域から場所をジオコーディングしようとしている可能性があります。

その場合は、Google の Geocoder (地図上に結果を表示する必要があります) など、他のジオコーダーがあります。

于 2012-08-25T16:42:22.400 に答える