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 provides styles from the ArcGIS Basemap styles family that are grouped into categories such as streets, topography, satellite, 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 below and follow the steps to create a new application.
Set up authentication
Create API key or user token developer credentials in your portal for the type of authentication you selected.
Set developer credentials
Use the API key or OAuth developer credentials created in the previous step in your application.
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
that is centered on the world.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] }); 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 }); </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: