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
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.7.0/ol.css"> <script src="https://cdn.jsdelivr.net/npm/ol@v10.7.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 and data attribution in all applications that use Esri technology.
-
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 layer centered on the world.What's next?
Learn how to use additional location services in these tutorials:


