You can customize your map for a specific country or region in the following ways:
- Change the default language settings.
- Specify a region code, which alters the map's behavior based on a given country or territory.
Language localization
By default, the Maps JavaScript API uses the user's preferred
language setting as specified in the browser, when displaying textual
information such as the names for controls, copyright notices, driving
directions and labels on maps. In most cases, it's preferable to respect the
browser setting. However, if you want the
Maps JavaScript API to ignore the browser's
language setting, you can force it to display information in a particular
language by adding a language
parameter to the
<script>
tag when loading the
Maps JavaScript API code.
The language
parameter affects the names of controls, copyright
notices, driving directions, and control labels, as well as the responses to
service requests. The effect on services is not as apparent. For example, when
geocoding street level addresses the country name is returned in the language
you requested, but the rest of the address will be specific to the location
you are geocoding. On the other hand, postal and political results are
returned in the requested language.
Try
this demo to experiment with the changes on the map when you update the
language
parameter.
The following example displays a map in Japanese and sets the region to Japan:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=ja®ion=JP"> </script>
If you set the language of the map, it's important to consider setting the region too. This helps ensure that your application complies with local laws.
Note: When you load the API in the manner shown above, the map uses the Japanese language for all users regardless of user preferences. Be sure you want this behavior before setting this option.
The Maps JavaScript API also supports bi-directional
(Bidi) text containing characters in both left-to-right (LTR) and
right-to-left (RTL) languages natively. Examples of RTL languages include
Arabic, Hebrew, and Farsi. Generally, you should specify RTL language pages to
render properly by adding dir='rtl'
to the page's
<html>
element. The following example renders a map of
Cairo, Egypt using Arabic controls:
<!DOCTYPE html> <html dir="rtl"> <body> <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=ar®ion=EG"> </script> </body> </html>
See the list of supported languages. Note that new languages are added often, so this list may not be exhaustive.
Region localization
When you load the Maps JavaScript API from
maps.googleapis.com
it applies a default bias for application
behavior towards the United States. If you want to alter your application to
serve different map tiles or bias the application (such as biasing geocoding
results towards the region), you can override this default behavior by adding
a region
parameter to the <script>
tag when
loading the Maps JavaScript API code.
As the developer of a Maps JavaScript API application it is your responsibility to ensure that your application complies with local laws by ensuring that the correct region localization is applied for the country in which the application is hosted.
The region
parameter accepts
Unicode region subtag identifiers which (generally) have a
one-to-one mapping to country code Top-Level Domains (ccTLDs). Most Unicode
region identifiers are identical to ISO 3166-1 codes, with some notable
exceptions. For example, Great Britain's ccTLD is "uk" (corresponding to the
domain .co.uk
) while its region identifier is "GB."
Try
this demo to experiment with the changes on the map when you update the
region
parameter.
For example, the following script tag localizes the map to the United Kingdom:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY®ion=GB"> </script>
The following examples show two maps, one which geocodes "Toledo" based on
the default region (US) to "Toledo, Ohio" and one which biases results based
on a region
set to ES
(Spain) to "Toledo,
Spain."
View the US example and the ES example.
Localization Demo
When setting the language of the map, it's important to consider setting the region too. Here is a demo that allows you to load the map with your choice of language and region.
View this demo in fullscreen.