views:

138

answers:

2

How to localize Google Map on my site?

+2  A: 

You need to add an hl parameter to your JavaScript line:

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

For the supported language parameters look here.

tomlog
+1  A: 

If your language is one that Google support, then you just need to specify the hl parameter when you load the API and use the locale setting when you use GDirections

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

If your language is not one that Google supports, then you need to perform lots of GAddMessages() calls, which is how the Google Maps API loader does it. But that leaves three types of text that either don't use that mechanism, or use the values set by the loader before we get control. These are the map types, the copyright texts, and GDirections.

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

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

  • There's no reasonable way to produce GDirections details in unsupported languages.

Mike Williams