簡體   English   中英

無法從經緯度獲取地址

[英]Not getting Address from latitude and longitude

我正在使用以下代碼從當前緯度和經度獲取地址,但是我無法獲得正確的響應

- (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覆蓋范圍較差; 看到這個文件 您可能正在嘗試對覆蓋不良的區域進行地理位置編碼。

在這種情況下,還有其他地理編碼器,例如Google的Geocoder (要求您在地圖上顯示結果)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM