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 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
An ArcGIS Location Platform account.
Steps
Get the starter app
Select a type of authentication below and follow the steps to create a new application.
Set up authentication
Create developer credentials in your portal for the type of authentication you selected.
Set developer credentials
Use the API key or OAuth developer credentials so your application can access location services.
Update script references
The map will use static basemap tiles as its basemap layer. Therefore, you remove references to the esri-leaflet-vector
plugin and the vector basemap layer. Then, you reference the static
plugin.
-
Remove the script references to
esri-leaflet-vector
plugin.Use dark colors for code blocks <head> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <title>Esri Leaflet Tutorials: Display a map</title> <!-- Load Leaflet from CDN --> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" crossorigin="" /> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" crossorigin=""></script> <!-- Load Esri Leaflet from CDN --> <script src="https://unpkg.com/esri-leaflet@3.0.16/dist/esri-leaflet.js"></script> <script src="https://unpkg.com/esri-leaflet-vector@4.2.8/dist/esri-leaflet-vector.js"></script>
-
Remove the
basemap
andEnum vector
references.Basemap Layer Use dark colors for code blocks const map = L.map("map", { minZoom: 2 }) map.setView([34.02, -118.805], 13); const basemapEnum = "arcgis/streets"; L.esri.Vector.vectorBasemapLayer(basemapEnum, { token: accessToken }).addTo(map);
-
Add
<script
tag to reference the> static
plugin.Basemap Tile Layer Use dark colors for code blocks <!-- Load Leaflet from CDN --> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" crossorigin="" /> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" crossorigin=""></script> <!-- Load Esri Leaflet from CDN --> <script src="https://unpkg.com/esri-leaflet@3.0.16/dist/esri-leaflet.js"></script> <script src="https://unpkg.com/esri-leaflet-static-basemap-tile@1/dist/esri-leaflet-static-basemap-tile.js"></script>
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 basemap layer 1
Use the Tiled
class to access and display basemap layer from the World Imagery map tile service.
- Access the map tile layer with
Tiled
. Then, add it to your 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);
Add basemap layer 2
In this step, you add another basemap layer from the static basemap tiles service to provide place labels.
- Add the
arcgis/imagery/labels
basemap style from the static basemap tiles service to display labels on top of the map tile layer.Use dark colors for code blocks const basemapEnum = "arcgis/imagery/labels"; L.esri.Static.staticBasemapTileLayer(basemapEnum, { token: accessToken }).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 ArcGIS location services in these tutorials: