Learn how to overlay a static basemap layer with a map tile layer.
The static basemap tiles service provides access to raster basemap tiles for the world. The service supports a number of ArcGIS styles, including arcgis/imagery/labels
and arcgis/oceans/labels
that you can overlay on top of existing map tile layers.
In this tutorial, you overlay the arcgis/imagery/labels
static basemap tiles with the World Imagery tile layer to provide place labels and geographic context.
Prerequisites
An ArcGIS Location Platform account.
Steps
Get the starter app
Select a type of authentication below and follow the steps to create a new application.
Set up authentication
Create 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.
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
cesium
variable and replaceAccess Token YOUR
with 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 viewer.camera.setView({ destination: Cesium.Cartesian3.fromDegrees(-98.5795, 39.8283, 1000000) });
Add map tile layer
Use the Cesium.
to access and display data from the World Imagery map tile service.
-
Create a
tile
fromLayer 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. The b
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
You will add a basemap layer using the Cesium.
with the arcgis/imagery/labels
style from the static basemap tiles service. This basemap layer will be placed on top of the existing tile layer.
-
Create a
basemap
fromLayer Cesium.
and pass in theArcGis Map Server Imagery Provider arcgis/imagery/labels
style from the static basemap tiles service.Use dark colors for code blocks const staticBasemapImagery = 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 basemap layer is created, add it on top of the map tile layer so it overlays correctly.
Use dark colors for code blocks const staticBasemapImagery = 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(staticBasemapImagery));
Run the app
Run the app.
The map should display map tiles from the World Imagery map tile service overlaid with labels from the static basemap tiles service.What's next?
Learn how to use additional ArcGIS location services in these tutorials: