Map Localization
Learn how to localize a map using the Google Maps JS API.
We'll cover the following
We can customize a map for a specific country or region by changing its default language settings or specifying a region code. This changes the map’s behavior based on the country.
Localize a map
The Maps JavaScript API adapts to the user’s preferred language setting specified in the browser by default. However, the map can be forced to display information in another language if the language
parameter is added to the URL in the script
tag when the Maps JavaScript API is loaded.
In the code snippet below, two-character language and region codes are added in respective placeholders of the country whose map needs to be localized:
src="https://maps.googleapis.com/maps/api/js?callback=initMap&language=<Language Code Here>
®ion=<Region Code Here>&key={{API_KEY}}"
Note: The
language
parameter affects the names of the controls, driving directions, and control labels.
When the API loads, it applies a default localization bias in favor of the United States throughout the application. We can override this default behavior by adding a region
tag when the Maps JS API code is added. Here’s a list of supported regions. It’s also a good idea to set the region at the same time the language of the map is set.
Code example
Below is an example that displays a map centered on Beijing, China:
In the above code widget, setting the region to China localizes the map to the Chinese language. It also biases the geocoding results in lines 13–14 of the HTML file.