Learn how to use the ArcGIS Static Basemap Tiles service to display a raster tile basemap.
The ArcGIS Static Basemap Tiles service
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
A public application is an application that allows anonymous access without requiring users to sign in with an ArcGIS account. It supports API key or app authentication. that access ArcGIS Location ServicesArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. and secure itemsAn item, also known as a content item, is a resource stored in a portal such as a web map, hosted layer, style, script tool, file, or notebook. . - 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
An ArcGIS account is an identity with a user type and set of privileges that can access specific ArcGIS products, tools, APIs, services, and resources. The main account types that can be used for development are an ArcGIS Location Platform account, ArcGIS Online account, and ArcGIS Enterprise account. ArcGIS Location Platform and ArcGIS Online accounts are also associated with a subscription. 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
Set developer credentials
Add script references
You will need add <script and <link tags to load the JavaScript and CSS files for OpenLayers and ol-mapbox-style.
-
In the index.html file, add the following
<linkand> <scriptreferences if they are missing.> Use dark colors for code blocks <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v10.9.0/ol.css"> <script src="https://cdn.jsdelivr.net/npm/ol@v10.9.0/dist/ol.js"></script>
Create a map
Use the Map and View classes to create an OpenLayers map.
-
Use the
Mapclass to create a map. Set thetargetproperty to"map", which is the id of thedivelement. To center the map view, set thecenterproperty to-20, 30and thezoomproperty to3.Use dark colors for code blocks const map = new ol.Map({ target: "map", view: new ol.View({ center: ol.proj.fromLonLat([-20, 30]), zoom: 3 }) });
Add a basemap layer
-
Create a
basemapvariable and set it toId arcgis/navigation. To find a list of basemap styles, go to Introduction to the Static Basemap Tiles service .Use dark colors for code blocks const basemapId = "arcgis/navigation"; -
Construct the basemap URL based on
basemapand your API key.Id Use dark colors for code blocks const basemapId = "arcgis/navigation"; const basemapURL = "https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1"; -
Create a
Tileobject that will provide basemap tiles to the map. Passbasemapinto the tile source's URL.Id 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 basemapId = "arcgis/navigation"; const basemapURL = "https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1"; const tileLayer = new ol.layer.Tile({ source: new ol.source.XYZ({ url: `${basemapURL}/${basemapId}/static/tile/{z}/{y}/{x}?token=${accessToken}`, // Default basemap tileSize: 512 }) }); const map = new ol.Map({ target: "map", view: new ol.View({ center: ol.proj.fromLonLat([-20, 30]), zoom: 3 }) }); </script> -
Pass the
tileinto the map'sLayer layersattribute.Use dark colors for code blocks const map = new ol.Map({ target: "map", layers: [tileLayer], view: new ol.View({ center: ol.proj.fromLonLat([-20, 30]), zoom: 3 }) });
Add attribution
You need to display Esri
-
Fetch the
copyrightfrom the service URL. Then, display it and prepend Powered by Esri string in the map's attribution control.Text Use dark colors for code blocks fetch(`${basemapURL}/${basemapId}/static?token=${accessToken}`) .then((response) => response.json()) .then((data) => { tileLayer .getSource() .setAttributions("Powered by <a href='https://www.esri.com/en-us/home' target='_blank'>Esri</a> | " + [data.copyrightText]); });
Run the app
Run the app.
The map should display the ArcGIS Navigation basemap layerWhat's next?
Learn how to use additional location services in these tutorials:


