Learn how to add multiple basemap layers from different services to your map.
This tutorial shows how to display two basemap layers from different services in your application. You will use the World Imagery map tile service satellite imagery basemap to provide the underlying visual and geographic context for the map. To provide additional context, you will use the arcgis/imagery/labels
style from the ArcGIS Static Basemap Tiles service to display place labels for the world. The combination of the two layers will result in a basemap that provides additional context for the mapping application.
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 that access ArcGIS Location Services and secure items.
- 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 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 so your application can access ArcGIS services.
Update the map's viewpoint
-
Change the map's center to
[37.1174, -91.2996]
and zoom level to5
. This will focus the map on the United States of America.Use dark colors for code blocks const map = L.map("map", { minZoom: 2 }).setView([37.1174, -91.2996], 5);
Add a second basemap layer
Use the Tiled
class to access and display basemap layer from the World Imagery map tile service alongside existing static basemap tile layer.
-
Modify the basemap style to
arcgis/imagery/labels
.Use dark colors for code blocks const basemapEnum = "arcgis/imagery/labels"; L.esri.Static.staticBasemapTileLayer(basemapEnum, { token: accessToken }).addTo(map);
-
Add another basemap layer from the World Imagery map tile service with
tiled
to the map.Map Layer Use dark colors for code blocks const tileLayer = L.esri.tiledMapLayer({ url: "https://ibasemaps-api.arcgis.com/arcgis/rest/services/World_Imagery/MapServer", token: accessToken }); tileLayer.addTo(map);
Run the app
Run the app.
The map should display basemap layers from the World Imagery map tile service and the Static Basemap Tiles service.What's next?
Learn how to use additional location services in these tutorials: