Learn how to use the ArcGIS Static Basemap Tiles service to display a raster tile basemap.
The ArcGIS Static Basemap Tiles service provides basemap data as pre-rendered and pre-styled map tiles for the world. The service rovides styles from the ArcGIS Basemap style family that are grouped into categories such as streets, topography, reference, and creative.
In this tutorial, you display the ArcGIS Navigation basemap style provided by the service.
Prerequisites
You need an ArcGIS Location Platform account.
ArcGIS Online and ArcGIS Enterprise accounts are not supported.
Steps
Create a new 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
Create API key or OAuth developer credentials in your portal for the type of authentication you selected.
Set developer credentials
Add script references
To access raster basemap layers, you need to reference the leaflet
libraries as well as the esri-leaflet
and esri-leaflet-static-basemap-tile
packages.
-
In the index.html file, add the following
<link
and> <script
references if they are missing.> 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"> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script> <!-- Load Esri Leaflet from CDN --> <script src="https://unpkg.com/esri-leaflet@3.0.19/dist/esri-leaflet.js"></script> <script src="https://unpkg.com/esri-leaflet-static-basemap-tile@1.1.1/dist/esri-leaflet-static-basemap-tile.js"></script>
Create a map
Use a map
to add a map to the div
element with the basemap you specify. To find a list of basemap styles, go to Introduction to the Static Basemap Tiles service .
-
In the
<script
tag, create a> map
with themin
set toZoom 2
.Use dark colors for code blocks const map = L.map("map", { minZoom: 2 });
-
Call the
set
method to center the map on the coordinatesView 30, -20
and to set the zoom level to3
.Use dark colors for code blocks const map = L.map("map", { minZoom: 2 }); map.setView([30, -20], 3);
-
Create a
basemap
variable to store the basemap identifier,Enum arcgis/navigation
.Use dark colors for code blocks const map = L.map("map", { minZoom: 2 }); map.setView([30, -20], 3); const basemapEnum = "arcgis/navigation";
-
Instantiate the
L.esri.
class and set theStatic.static Basemap Layer basemap
andEnum access
before adding the layer to theToken map
.Use dark colors for code blocks const basemapEnum = "arcgis/navigation"; L.esri.Static.staticBasemapTileLayer(basemapEnum, { token: accessToken }).addTo(map);
Run the app
Run the app.
The map should display the ArcGIS Navigation basemap layer centered on the world.What's next?
Learn how to use additional location services in these tutorials: