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
Create a map
-
Create a
basemap
andEnum base
to reference the style URL forUrl arcgis/navigation
.Use dark colors for code blocks <script> /* 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: "https://www.arcgis.com/sharing/rest" // Your portal URL // }) // const accessToken = session.token; const basemapEnum = "arcgis/navigation"; const baseUrl = "https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1"; </script>
-
Create a
Map
with a raster tile source that loads tiles from the Static Basemap Tiles service using thebasemap
as the default style.Enum Use dark colors for code blocks <script> /* 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: "https://www.arcgis.com/sharing/rest" // Your portal URL // }) // const accessToken = session.token; const basemapEnum = "arcgis/navigation"; const baseUrl = "https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1"; const map = new maplibregl.Map({ container: "map", style: { version: 8, sources: { "raster-tiles": { type: "raster", tiles: [ `${baseUrl}/${basemapEnum}/static/tile/{z}/{y}/{x}?token=${accessToken}` ], tileSize: 512 } }, layers: [ { id: "simple-tiles", type: "raster", source: "raster-tiles", minzoom: 0, maxzoom: 22 } ] }, zoom: 2, center: [-20, 30] }); </script>
-
Create a
fetch
request to retrieve and display the required Esri and data attribution on the map.Use dark colors for code blocks const map = new maplibregl.Map({ container: "map", style: { version: 8, sources: { "raster-tiles": { type: "raster", tiles: [ `${baseUrl}/${basemapEnum}/static/tile/{z}/{y}/{x}?token=${accessToken}` ], tileSize: 512 } }, layers: [ { id: "simple-tiles", type: "raster", source: "raster-tiles", minzoom: 0, maxzoom: 22 } ] }, zoom: 2, center: [-20, 30] }); fetch(`${baseUrl}/${basemapEnum}/static?token=${accessToken}`) // Display required Esri and data attribution .then((response) => response.json()) .then((data) => { map._controls[0]._innerContainer.innerText += " | Powered by Esri | " + data.copyrightText; });
Run the app
Run the app.
The map should display thearcgis/navigation
style from the Static Basemap Styles service.
What's next?
Learn how to use additional location services in these tutorials: