Learn how to display a scene with styled basemap tiles.
You can display a CesiumJS with ArcGIS styled basemap tiles. The ArcGIS Static Basemap Tiles service provides basemap data as pre-styled raster tiles for the world. The service provides 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
Set developer credentials
Get a Cesium ion access token
All Cesium applications must use an access token provided through Cesium ion. This token allows you to access assets such as Cesium World Terrain in your application.
-
Go to your Cesium ion dashboard to generate an access token. Copy the key to your clipboard.
-
Create a
cesiumvariable and replaceAccess Token YOURwith the access token you copied from the Cesium ion dashboard._CESIUM _ACCESS _TOKEN 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: "YOUR_PORTAL_URL" // Your portal URL // }) // const accessToken = session.token; Cesium.ArcGisMapService.defaultAccessToken = accessToken; const cesiumAccessToken = "YOUR_CESIUM_ACCESS_TOKEN"; </script> -
Configure
Cesium.with the Cesium access token to validate the application.Ion.default Access Token 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: "YOUR_PORTAL_URL" // Your portal URL // }) // const accessToken = session.token; Cesium.ArcGisMapService.defaultAccessToken = accessToken; const cesiumAccessToken = "YOUR_CESIUM_ACCESS_TOKEN"; Cesium.Ion.defaultAccessToken = cesiumAccessToken; </script>
Add script references
-
In the index.html file, add the following
<linkand> <scriptreferences if they are missing.> Use dark colors for code blocks <meta charset="utf-8"> <title>CesiumJS: Display a Scene</title> <script src="https://cesium.com/downloads/cesiumjs/releases/1.135/Build/Cesium/Cesium.js"></script> <link href="https://cesium.com/downloads/cesiumjs/releases/1.135/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
Create a scene
Set up your CesiumJS scene by creating a viewer and positioning the camera over the United States of America.
-
Create a
Viewerattached to thecesiumelement. Disable the timeline, animation, and geocoder controls.Container Use dark colors for code blocks const viewer = new Cesium.Viewer("cesiumContainer", { baseLayerPicker: false, timeline: false, animation: false, geocoder: false }); -
Use
viewer.camera.setto set the camera's position and extent to the United States of America.View Use dark colors for code blocks viewer.camera.setView({ destination: Cesium.Cartesian3.fromDegrees(-91.2996, 37.1174, 12000000) });
Add imagery provider
Use Url to add a raster basemap from the Static Basemap Tiles service.
-
Create a
basemapvariable and construct the base service URL.Enum Use dark colors for code blocks const basemapEnum = "arcgis/navigation"; const baseUrl = `https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1/${basemapEnum}/static`; -
Create the imagery provider with
Url.Template Imagery Provider Use dark colors for code blocks const basemapEnum = "arcgis/navigation"; const baseUrl = `https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1/${basemapEnum}/static`; const imageryProvider = new Cesium.UrlTemplateImageryProvider({ url: `${baseUrl}/tile/{z}/{y}/{x}?token=${accessToken}`, tileWidth: 512, tileHeight: 512 }); -
Add it to the viewer's
imagery.Layers Use dark colors for code blocks viewer.imageryLayers.addImageryProvider(imageryProvider);
Add attribution
You need to display Esri and data attribution in all applications that use Esri technology.
-
Create a new
Creditfor the Powered by Esri string withshowset toOn Screen trueand then add it to the viewer.Use dark colors for code blocks // Add Esri attribution // Learn more in https://esriurl.com/attribution const poweredByEsri = new Cesium.Credit("Powered by <a href='https://www.esri.com/en-us/home' target='_blank'>Esri</a>", true); viewer.creditDisplay.addStaticCredit(poweredByEsri);
Run the app
Run the app.
The map should display thearcgis/navigation base layer centered on the United States of America.
What's next?
Learn how to use additional location services in these tutorials:


