If you have an existing CesiumJS application, it is easy to update your application to use ArcGIS Location Services
Base layers
You can replace Cesium's default Bing Maps Imagery and Cesium World Terrain layers with an ArcGIS map tile service
Examples
Bing Maps Imagery to ArcGIS image service
This example shows how to replace Cesium's Bing Maps Imagery with the ArcGIS:Imagery map tile service
-
Get an access token
An access token is an authorization string that provides access to secure ArcGIS content, data, and services. Its capabilities are determined by the privileges it supports. It is obtained by implementing API key authentication, User authentication, or App authentication. using API key credentials or implement another type of authentication in your application. -
Select a map tile service
A map tile service, formerly known as image tile service, is a data service that provides access to static, pre-rendered mao tiles. The tiles are typical in PNG format. Map tiles are typically retrieved by specifying a specific level, row, and column value. from the basemap layers page and copy the service URL.Use dark colors for code blocks const imageTileURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/ArcGIS:Imagery:Standard?type=style"; -
Create an
ArcGISthat references the copied service URL. Set theMap Server Imagery Provider tokenparameter to your API key or OAuth2 access token.Use dark colors for code blocks const imageTileURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/ArcGIS:Imagery:Standard?type=style"; const arcGISImageTileProvider = new Cesium.ArcGisMapServerImageryProvider({ url : imageTileURL, token: accessToken }); -
Set the
imageryof theProvider Viewerto the new ArcGIS imagery provider.Use dark colors for code blocks const imageTileURL = "https://basemaps-api.arcgis.com/arcgis/rest/services/styles/ArcGIS:Imagery:Standard?type=style"; const arcGISImageTileProvider = new Cesium.ArcGisMapServerImageryProvider({ url : imageTileURL, token: accessToken }); const elevationURL = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" const viewer = new Cesium.Viewer("cesiumContainer", { imageryProvider: arcGISImageTileProvider, });
Cesium World Terrain to ArcGIS Elevation service
This example shows how to replace Cesium World Terrain with an ArcGIS Elevation service
-
Remove the Cesium terrain provider from the
Viewer.Use dark colors for code blocks const viewer = new Cesium.Viewer("cesiumContainer", { terrainProvider: Cesium.createWorldTerrain(), }); -
Copy the URL of the ArcGIS World Elevation service.
Use dark colors for code blocks const elevationURL = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" -
Create a new
ArcGISthat references the copied service URL. Set theTiled Elevation Terrain Provider tokenparameter to your ArcGIS API key or OAuth2 access token.Use dark colors for code blocks const elevationURL = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" const terrainProvider = new Cesium.ArcGISTiledElevationTerrainProvider({ url : elevationURL, token : accessToken }); -
Set the
terrainof theProvider Viewerto the new ArcGIS terrain provider.Use dark colors for code blocks const elevationURL = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" const terrainProvider = new Cesium.ArcGISTiledElevationTerrainProvider({ url : elevationURL, token : accessToken }); const viewer = new Cesium.Viewer("cesiumContainer", { terrainProvider: arcGISTerrainProvider, });
Data services
You can securely publish your data in ArcGIS to create hosted layers
You can display hosted layers in CesiumJS with the following classes:
- Feature layers
A feature layer (client-side) is a data layer that can access and display features from a feature service that has the same type of geometry and attribute fields. :Geo.Json Data Source - Scene layers
A scene layer is a data layer is used to access and display 3D data from a scene service. :I3.S Data Provider - Map tile layers
A hosted map tile layer is a hosted layer (item) in a portal that is used to manage the properties and settings of a map tile service. :ArcGisMap Server Imagery Provider
Example
GeoJSON to hosted feature layer
This example shows how to convert GeoJSON stored in Cesium ion to a hosted feature layer
-
Remove the existing
Geofrom your code.Json Data Source Use dark colors for code blocks Cesium.IonResource.fromAssetId(1556114).then((asset) => { const layer = Cesium.GeoJsonDataSource.load(asset); viewer.dataSources.add(layer); }) ; -
Go to the Cesium ion dashboard > Assets. Select the GeoJSON asset that you want to re-host as a feature layer. In the right panel, click Source Files > Download.
-
Upload your GeoJSON file to your portal
ArcGIS portal, also known as a portal, is a website with applications and tools that can be used to create, manage, access, and share geospatial content and data. It supports security and authentication, developer credentials, content and data service management, user and group management, and site administration. A portal can be hosted in Esri's infrastructure or your own infrastructure. and convert it to a hosted feature layerA hosted feature layer is a hosted layer (item) in a portal that is used to manage the properties and settings of a spatially-enabled feature layer in a feature service. . To learn how to do this, go to the Import data as a feature layer tutorial. -
Use ArcGIS REST JS to query the new feature service in your CesiumJS application. Format the response as GeoJSON.
Use dark colors for code blocks const authentication = arcgisRest.ApiKeyManager.fromKey(accessToken); const layerURL = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0"; arcgisRest.queryFeatures({ url: layerURL, authentication, f:"geojson" }) -
Add the response from the ArcGIS REST JS request to the viewer as a new
Geo.Json Data Source Use dark colors for code blocks const authentication = arcgisRest.ApiKeyManager.fromKey(accessToken); const layerURL = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0"; arcgisRest.queryFeatures({ url: layerURL, authentication, f:"geojson" }) .then(response => { const layer = Cesium.GeoJsonDataSource.load(response) viewer.dataSources.add(layer); });
Geocoding
The ArcGIS Geocoding service
Example
Cesium Geocoding to ArcGIS Geocoding
This example shows how to disable the Cesium Geocoder and add ArcGIS geocoding to your application.
-
Disable the Cesium
geocoderin the viewer. -
Create a function that uses the ArcGIS REST JS
geocodefunction to make a request to the ArcGIS Geocoding serviceA geocoding service is a service that can search for addresses, place addresses, businesses, reverse geocode coordinates to addresses, provide suggestions for places, and perform bulk geocoding. It is hosted by Esri as the ArcGIS Geocoding service and can also be hosted in ArcGIS Enterprise. . -
Create an HTML input and add an event listener to call the REST JS function when the user clicks a button.
-
Display the results from the Geocoding service as a Cesium
Entity.