如何从reverseGeocodeLocation本地化地址结果? [英] how to localize address result from reverseGeocodeLocation?
本文介绍了如何从reverseGeocodeLocation本地化地址结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的iphone应用程序应该根据用户的经度和经度来解析地址。
reverseGeocodeLocation工作正常,但结果是英文。
My iphone app supposed to resolve address based on latitude and longitude of the user. reverseGeocodeLocation works fine, but results are in english.
有没有办法将结果本地化为其他语言?
Is there a way to localize the results to other languages?
无法在苹果或其他任何地方找到有关它的任何信息。
couldnt find any information about it at apple or anywhere else.
我使用的代码是:
CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
CLLocation *location = [[[CLLocation alloc]
initWithLatitude:coord.latitude longitude:coord.longitude] autorelease];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
[self displayError:error];
return;
}
if(placemarks && placemarks.count > 0)
{
//do something
CLPlacemark *topResult = [placemarks objectAtIndex:0];
NSString *addressTxt = [NSString stringWithFormat:@"%@ %@,%@ %@",
[topResult subThoroughfare],[topResult thoroughfare],
[topResult locality], [topResult administrativeArea]];
}
}
推荐答案
i找到了如何本地化国家名称,也许它会有所帮助:
i found how to localize country name, maybe it'll help:
CLPlacemark *placemark;
NSString *identifier = [NSLocale localeIdentifierFromComponents: [NSDictionary dictionaryWithObject: placemark.ISOcountryCode forKey: NSLocaleCountryCode]];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSString *country = [usLocale displayNameForKey: NSLocaleIdentifier value: identifier];
插入任何国家ID而不是@en_US
insert any country id instead @"en_US"
这篇关于如何从reverseGeocodeLocation本地化地址结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文