我无法在两个不同的坐标系统中从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";
}
问题是为什么我没有获取到所有的信息。例如城市、邮政编码等都缺失了。在程序中如何处理这个问题。
[geocoder reverseGeocodeLocation:tempLocation completionHandler: ^(NSArray placemarks, NSError error){ if ([placemarks count] > 0) { CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@" %@",placemark.addressDictionary); }}]; - Black Tiger