3

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];
Mansfield
  • 14,445
  • 18
  • 76
  • 112
Stathis
  • 41
  • 4

2 Answers2

3

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
Felix
  • 35,354
  • 13
  • 96
  • 143
  • Thats really cool, with this way you don't need to add if define branches inside of your code. Thanks @phix23 It was helped me lot. – fyasar Oct 16 '11 at 12:50
1

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.

Community
  • 1
  • 1
natas-dk
  • 21
  • 4