Learn how to add map tiles from a map tile service to a scene.
Map tiles are a type of tile data that are stored in an map tile service. They typically display raster imagery, such as aerial photography, but can also be used to display other data. You can create an map tile service by publishing a feature service in your portal.
In this tutorial, you use CesiumJS to display the Kilauea Volcano Shortwave Infrared map tile layer.
Prerequisites
An ArcGIS Location Platform or ArcGIS Online 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 <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 <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 position
-
Update the camera position to
-154.9051879, 19.451828, 22000
to focus on the Big Island of Hawaii.viewer.camera.setView({ destination: Cesium.Cartesian3.fromDegrees(-154.9051879, 19.451828, 22000), })
Add a map tile layer
-
Create a new
Cesium.
that references the Kilauea Volcano Shortwave Infrared map tile layer.ArcGis Map Server Imagery Provider // 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); const tileLayer = Cesium.ArcGisMapServerImageryProvider.fromUrl("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/WV03_Kilauea_20180519_ShortwaveInfrared/MapServer", { token: accessToken, }); viewer.scene.imageryLayers.add( Cesium.ImageryLayer.fromProviderAsync(tileLayer) );
-
Add the data attribution for the tile layer source.
- Go to the Kilauea Volcano Shortwave Infrared item.
- Scroll down to the Credits (Attribution) section and copy its value.
- Set the
credit
property in the object to the attribution value from the item.const tileLayer = Cesium.ArcGisMapServerImageryProvider.fromUrl("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/WV03_Kilauea_20180519_ShortwaveInfrared/MapServer", { token: accessToken, // Attribution text retrieved from https://www.arcgis.com/home/item.html?id=0dcf7df9bfb342cc9e0119f6da7daa45 credit: new Cesium.Credit('Esri, Digital Globe', false) }); viewer.scene.imageryLayers.add( Cesium.ImageryLayer.fromProviderAsync(tileLayer) );
Run the app
Run the app.
You should see a map tile layer of the Kilauea Volcano lava flow in the Big Island of Hawaii.What's next?
Learn how to use additional ArcGIS location services in these tutorials: