【问题标题】:CLGeocoder reverseGeocodeLocation not able to product consisent resultCLGeocoder reverseGeocodeLocation 无法产生一致的结果
【发布时间】:2012-07-19 11:07:00
【问题描述】:

对于两个不同的坐标系,我无法从 CLGeocoder reverseGeocodeLocation 获得相同的结果。 例如。

CLLocation *tempLocation = [[CLLocation alloc] initWithLatitude:37.785834 longitude:-122.406417]; // coordinate for apple head quater
CLGeocoder *geocoder = [[CLGeocoder alloc] init];    
[geocoder reverseGeocodeLocation:tempLocation completionHandler:
 ^(NSArray* placemarks, NSError* error){
     if ([placemarks count] > 0)
     {
         CLPlacemark *placemark = [placemarks objectAtIndex:0];             
         NSLog(@" %@",placemark.addressDictionary); 
     }
 }];

输出:

City = "San Francisco";
Country = "United States";
CountryCode = US;
FormattedAddressLines =     (
    "Apple Store, San Francisco",
    "1 Stockton St",
    "San Francisco, CA  94108-5805",
    "United States"
);
Name = "Apple Store, San Francisco";
PostCodeExtension = 5805;
State = California;
Street = "1 Stockton St";
SubAdministrativeArea = "San Francisco";
SubLocality = "Union Square";
SubThoroughfare = 1;
Thoroughfare = "Stockton St";
ZIP = 94108;

但是当我使用

CLLocation tempLocation = [[CLLocation alloc] initWithLatitude:27.672654 longitude:85.313744]; 
///CLLocation *tempLocation = [[CLLocation alloc] initWithLatitude:37.785834 longitude:-122.406417]; 
CLGeocoder *geocoder = [[CLGeocoder alloc] init]; 
[geocoder reverseGeocodeLocation:tempLocation completionHandler: 
 ^(NSArray placemarks, NSError* error) { 
    if ([placemarks count] > 0) { 
        CLPlacemark *placemark = [placemarks objectAtIndex:0]; 
        NSLog(@" %@",placemark.addressDictionary); 
    }
}]; 

输出是

{ 
Country = Nepal; 
CountryCode = NP; 
FormattedAddressLines = ( "Pulchowk Road", Nepal ); 
Name = "Pulchowk Road"; 
State = Bagmati; 
Street = "Pulchowk Road"; 
Thoroughfare = "Pulchowk Road"; 
} 

问题是为什么我没有获得所有信息。例如 City , ZIP .. 丢失。我应该如何在程序中处理这个问题。

【问题讨论】:

  • 请将代码放在“在此处输入代码”的位置
  • CLLocation tempLocation = [[CLLocation alloc] initWithLatitude:27.672654 longitude:85.313744]; ///CLLocation *tempLocation = [[CLLocation alloc] initWithLatitude:37.785834 longitude:-122.406417]; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:tempLocation completionHandler: ^(NSArray placemarks, NSError* error){ if ([placemarks count] > 0) { CLPlacemark *placemark = [placemarks objectAtIndex:0]; NSLog(@" %@",placemark.addressDictionary); }}];
  • 输出是 { Country = Nepal;国家代码 = NP; FormattedAddressLines = ("Pulchowk Road", 尼泊尔);名称=“Pulchowk路”;状态 = 巴格马蒂;街道 = "Pulchowk 路"; Thoroughfare = "Pulchowk 路"; }

标签: iphone objective-c ios5 xcode4.2


【解决方案1】:

地理位置始终使用最佳可用信息。对于尼泊尔来说,与 Apple 或其服务提供商签约的地图公司很可能没有提供您所缺少的信息。这更像是一个合同/服务质量问题,我认为您无能为力。除非尝试优化您的应用程序以提供尽可能好的用户体验,即使它只有不完整的数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-03
    • 2012-01-16
    • 1970-01-01
    • 1970-01-01
    • 2012-03-20
    • 2017-06-10
    相关资源
    最近更新 更多