How to localize Google map correctly?

How do I localize a Google Map to my site ?

+2


source to share


2 answers


You need to add the hl parameter to your JavaScript string:

<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&hl=de" />

      



For the supported language options, see here .

+3


source


If your language supports google, you just need to specify the hl parameter when loading the API and using the locale parameter when using GDirections

  gdir.load("from: Detroit to: Dayton", {locale:"fr"});. 

      



If your language is not supported by Google, you need to make many GAddMessages () calls, as the Google Maps API loader does. But that leaves three types of text that either don't use this mechanism or use the values ​​set by the loader before we get control. These are map types, copyright texts and GDirections.

  • To localize the texts of the map types, you need to create your own map types, which are clones of Google map types, but with changed "name", "shortName", "errorMessage" and "alt" parameters.

  • To localize copyright texts, you can write your own custommap.getCopyrights () method that reads through the prefixes and replaces any occurrences of "Data Maps" and "Imagery" with the equivalent in the desired language.

  • No reasonable way to produce GDirections details in unsupported languages.

+1


source







All Articles