Learn how to change language labels in a map.
The ArcGIS Static Basemap Tiles servicelanguage parameter, which allows you to localize place labels. There are currently more than 5 different languages available.
In this tutorial, you use a <select dropdown menu to toggle between a number of different language labels for the static basemap tiles.
Prerequisites
You need an ArcGIS Location Platform account.
ArcGIS Online and ArcGIS Enterprise accounts are not supported.
Steps
Get the starter app
Select a type of authentication and follow the steps to create a new app.
Choose API key authentication if you:
- Want the easiest way to get started.
- Want to build public applications
A public application is an application that allows anonymous access without requiring users to sign in with an ArcGIS account. It supports API key or app authentication. that access ArcGIS Location ServicesArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. and secure itemsAn item, also known as a content item, is a resource stored in a portal such as a web map, hosted layer, style, script tool, file, or notebook. . - Have an ArcGIS Location Platform or ArcGIS Online account.
Choose user authentication if you:
- Want to build private applications.
- Require application users to sign in with their own ArcGIS account
An ArcGIS account is an identity with a user type and set of privileges that can access specific ArcGIS products, tools, APIs, services, and resources. The main account types that can be used for development are an ArcGIS Location Platform account, ArcGIS Online account, and ArcGIS Enterprise account. ArcGIS Location Platform and ArcGIS Online accounts are also associated with a subscription. and access resources their behalf. - Have an ArcGIS Online account.
To learn more about both types of authentication, go to Authentication.
Set up authentication
Set developer credentials
Use the API key or OAuth developer credentials
Update the map's viewpoint
-
Change the map's center to
[47.14, 8.90]and zoom level to7. This will focus the map on Switzerland.Use dark colors for code blocks Copy /* Use for API key authentication */ const accessToken = "YOUR_ACCESS_TOKEN"; // or /* Use for user authentication */ // const session = await arcgisRest.ArcGISIdentityManager.beginOAuth2({ // clientId: "YOUR_CLIENT_ID", // Your client ID from OAuth credentials // redirectUri: "YOUR_REDIRECT_URI", // The redirect URL registered in your OAuth credentials // portal: "YOUR_PORTAL_URL" // Your portal URL // }) // const accessToken = session.token; const map = L.map("map", { minZoom: 2 }); map.setView([47.14, 8.90], 7);
Add the language labels
You will get all the available languages for your selected basemap style and create a menu that allows users to change the display language of your map.
-
Remove the code that adds a basemap layer because you will load it dynamically from a menu instead.
Use dark colors for code blocks const basemapEnum = "arcgis/navigation"; L.esri.Static.staticBasemapTileLayer(basemapEnum, { token: accessToken }).addTo(map); -
Use the
getmethod fromSelf L.esri.to make a request to the Static Basemap Tiles service that returns all available basemap styles and their metadata.Static. Util Use dark colors for code blocks /* Use for API key authentication */ const accessToken = "YOUR_ACCESS_TOKEN"; // or /* Use for user authentication */ // const session = await arcgisRest.ArcGISIdentityManager.beginOAuth2({ // clientId: "YOUR_CLIENT_ID", // Your client ID from OAuth credentials // redirectUri: "YOUR_REDIRECT_URI", // The redirect URL registered in your OAuth credentials // portal: "YOUR_PORTAL_URL" // Your portal URL // }) // const accessToken = session.token; const map = L.map("map", { minZoom: 2 }); map.setView([47.14, 8.90], 7); const basemapStyle = "arcgis/navigation"; L.esri.Static.Util.getSelf(accessToken).then((data) => { }); -
Create a
languagesobject to store all the returned languages available forarcgis/navigation.Use dark colors for code blocks L.esri.Static.Util.getSelf(accessToken).then((data) => { const languages = {}; }); -
Iterate through each language and create an
L.esri., passing the language code to theStatic.static Basemap Tile Layer languageproperty. Store it inside thelanguagesobject.Use dark colors for code blocks L.esri.Static.Util.getSelf(accessToken).then((data) => { const languages = {}; data.languages.forEach((language) => { languages[language.name] = L.esri.Static.staticBasemapTileLayer(basemapStyle, { token: accessToken, language: language.code }); }); }); -
Create a
Layerscontrol that referenceslanguagesand add it to your map.Use dark colors for code blocks L.esri.Static.Util.getSelf(accessToken).then((data) => { const languages = {}; data.languages.forEach((language) => { languages[language.name] = L.esri.Static.staticBasemapTileLayer(basemapStyle, { token: accessToken, language: language.code }); }); L.control.layers(languages, null, { collapsed: false }).addTo(map); }); -
Append
addto theTo Frenchentry so that it is the default language when the application loads.Use dark colors for code blocks L.esri.Static.Util.getSelf(accessToken).then((data) => { const languages = {}; data.languages.forEach((language) => { languages[language.name] = L.esri.Static.staticBasemapTileLayer(basemapStyle, { token: accessToken, language: language.code }); }); L.control.layers(languages, null, { collapsed: false }).addTo(map); languages["French"].addTo(map); });
Run the app
Run the app.
The map should be displayed in French and you should be able to use the controls to switch between language labels.What's next?
Learn how to use additional location services in these tutorials:

