Learn how to display multiple basemap layers from different services to your scene.
This tutorial shows how to display two basemap layers from different services in your application. You will use the World Imagery map tile servicearcgis/imagery/labels style from the ArcGIS Static Basemap Tiles service
Prerequisites
You need an ArcGIS Location Platform account.
ArcGIS Online and ArcGIS Enterprise accounts are not supported.
Steps
Get the starter 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
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>
Update the camera viewpoint
-
Update the camera viewpoint to
[-98.5795, 39.8283]and scale to3000000. This will focus the map on the United States of America.Use dark colors for code blocks Copy viewer.camera.setView({ destination: Cesium.Cartesian3.fromDegrees(-98.5795, 39.8283, 1000000) });
Add basemap layer 1
Use the Cesium. to add a basemap layer from the World Imagery map tile service
-
Create a
tilefromLayer Cesium.and pass in the World Imagery map tile service.ArcGis Map Server Imagery Provider Use dark colors for code blocks const tileLayer = Cesium.ArcGisMapServerImageryProvider.fromUrl( "https://ibasemaps-api.arcgis.com/arcgis/rest/services/World_Imagery/MapServer", { token: accessToken } ); -
Once the tile layer is created, add it to the Cesium viewer's imagery layers. This basemap layer provides a visual context to your scene.
Use dark colors for code blocks const tileLayer = Cesium.ArcGisMapServerImageryProvider.fromUrl( "https://ibasemaps-api.arcgis.com/arcgis/rest/services/World_Imagery/MapServer", { token: accessToken } ); viewer.scene.imageryLayers.add(Cesium.ImageryLayer.fromProviderAsync(tileLayer));
Add basemap layer 2
Add another basemap layer using the Cesium. with the arcgis/imagery/labels style from the Static Basemap Tiles service
-
Create a
staticfromBasemap Tile Layer Cesium.and pass in theArcGis Map Server Imagery Provider arcgis/imagery/labelsstyle from the static basemap tiles service.Use dark colors for code blocks const staticBasemapTileLayer = new Cesium.UrlTemplateImageryProvider({ url: `https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1/arcgis/imagery/labels/static/tile/{z}/{y}/{x}?token=${accessToken}`, tileWidth: 512, tileHeight: 512, credit: "Powered by <a href='https://www.esri.com/en-us/home' target='_blank'>Esri</a>" }); -
Once the static basemap tile layer is created, add it on top of the map tile layer.
Use dark colors for code blocks const staticBasemapTileLayer = new Cesium.UrlTemplateImageryProvider({ url: `https://static-map-tiles-api.arcgis.com/arcgis/rest/services/static-basemap-tiles-service/v1/arcgis/imagery/labels/static/tile/{z}/{y}/{x}?token=${accessToken}`, tileWidth: 512, tileHeight: 512, credit: "Powered by <a href='https://www.esri.com/en-us/home' target='_blank'>Esri</a>" }); viewer.scene.imageryLayers.add(Cesium.ImageryLayer.fromProviderAsync(staticBasemapTileLayer));
Run the app
Run the app.
The scene should display basemap layers from the World Imagery map tile serviceWhat's next?
Learn how to use additional location services in these tutorials:

