Search code examples
iosgoogle-mapsgoogle-maps-sdk-iosreverse-geocodinggoogle-geocoding-api

Dynamically change the response language of Google Maps API for iOS


By using:

[[NSUserDefaults standardUserDefaults] setObject:@[language] forKey:@"AppleLanguages"];

I can set the response language of GMSGeocoder reverseGeocodeCoordinate.

But when i wanna change the response language when app is running, setting:

[[NSUserDefaults standardUserDefaults] setObject:@[theOtherLanguage] forKey:@"AppleLanguages"];

Again doesn't work.

I saw this solution for the Google Maps API for Javascript, anyone knows the similar solution for the iOS version ?


Solution

  • You may need to use the Geocoding API to receive these responses in a different language. See here for the Reverse Geocoding article, with the language parameter a few paragraphs down.

    You can make an NSURLRequest with the appropriate URL and language parameters. The response is in JSON format, so you should be able to handle this change dynamically within your code.