Reputation: 41
I am using MapKit and MKReverseGeocoder in order to convert lat/lon to location. I made some tests and realize that the geocoding response language is set according to iPhone's selected language. How do I set response language explicitly ? I want the response to be in 'en' no matter what. My code is:
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:center];
[geocoder setDelegate:self];
[geocoder start];
Upvotes: 3
Views: 1499
Reputation: 21
you can "trick" the app to think it's a specific "language"
see How to force NSLocalizedString to use a specific language
short answer put this in your main.m. In the "autorelease".
[[NSUserDefaults standardUserDefaults]
setObject:[NSArray arrayWithObject:@"en"]
forKey:@"AppleLanguages"];
for english geocoding
it might have other effects on your app if you use localization.
Upvotes: 1
Reputation: 35394
MKReverseGeocoder
(also CLGeocoder
in iOS5) does not allow you to set the language.
However you can build your own reverse geocoder using the Google Maps API. That requires to send an HTTP request and parse the response data. You can set set language in the URL. Here is a list of supported languages: https://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1
Example URL:
http://maps.google.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true&language=en
Upvotes: 3