Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the language of Google Maps on the run?

I wan't to reverse geocode and get the address in two languages arabic and english so I want to get it in one language then change the language of the API and get the address in the other language, as I can't find a parameter to send to geocoder to determine the language. Any suggestions?

like image 229
Ahmed Elmorsy Avatar asked Aug 15 '11 13:08

Ahmed Elmorsy


People also ask

Why can't I change the language on Google Maps?

Google Maps on the web: Click the menu in the top left, then click Language and select any language to set it. Google Maps app for Android: Tap your profile picture in the top right, tap Settings > Navigation settings > Voice selection > a language. To also adjust the text language go to Settings > App language.


1 Answers

A language can be selected when you load the API by appending language=XX to the API URL where XX is the two-character language code (en for English, ar for Arabic, etc.) to the URL in the API call. See http://code.google.com/apis/maps/documentation/javascript/basics.html#Localization for documentation.

This won't let you change it on the fly, and I don't think you can do that. You can try loading the API a second time after getting the initial info you need in one language. But that seems likely to cause problems.

A cleaner way to do it might be to create a separate page that acts as a sort of web service for you. It accepts two parameters: A language code and an address. It loads the API using the language code requested, and reverse geocodes the address, providing the result. Your page would call this web service-like thing twice, once for each language, and then use the results as desired.

like image 97
Trott Avatar answered Sep 19 '22 15:09

Trott