Display maps in other languages and worldviews
Developers can configure their maps to display labels and geographic features appropriate for specific audiences. These settings can be based upon device locale settings, current location, user preferences, hard-coded values, or any other mechanism the developer wishes to use.
No additional configuration is required to display maps in the language and worldview of the user's browser or device locale.
If you want to manually specify the language on your map, the code snippets in the next section show you how. You will learn how to configure maps to use a specific language and worldview as well as change the language and worldview dynamically after the map has loaded (for example, allowing the user to switch languages using a control).
Language selection prioritizes locally-appropriate feature names and alphabets. When data for the selected feature or language is not available, an appropriate fallback will be prioritized. For a list of supported languages, see the list of available languages.
Developers can also configure the worldview of the map. A worldview identifies geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. This most commonly affects how and whether disputed boundaries and labels are displayed. For a list of supported worldviews, see the list of available worldviews.
Maps that use either of these features are referred to as internationalized maps.
Setting the language and worldview of a Mapbox map
By default Mapbox maps will use the browser or device locale to determine the language and worldview of map labels and features. You can override this behavior to specify a particular language or worldview when initializing a map, or you can change the language and worldview dynamically after the map has loaded. The method for doing so varies by platform.
Setting the language and worldview in web maps (Mapbox GL JS)
These instructions are for GL JS v2.11.0 or later.
When instantiating a map, you can set the language and worldview options on the Map object to specify the language and worldview for map labels and features.
// Initialize a map with Chinese labels and features for a mainland Chinese audience
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/standard',
language: 'zh-Hans',
worldview: 'CN'
});
After a map has been initialized, you can change the language and worldview dynamically using setLanguage() and setWorldview() on the Map instance.
// Change language to English and worldview to US
map.setLanguage('en');
map.setWorldview('US');
Setting the language and worldview in mobile maps (iOS, Android, and Flutter)
These instructions are for Maps SDK v10.5.0 or later.
In Mapbox mobile maps, the same set of methods are called to set the language and worldview before map initialization and after the map has loaded. The method for doing so varies by platform, but the keys and values used to set the language and worldview are the same across platforms.