diff --git a/docs/developer-guide/maps-configuration.md b/docs/developer-guide/maps-configuration.md index 1c8653047c..3a6e5d6243 100644 --- a/docs/developer-guide/maps-configuration.md +++ b/docs/developer-guide/maps-configuration.md @@ -1232,6 +1232,24 @@ The `terrain` layer of `cesium` type allows using Cesium terrain format complian } ``` +##### Cesium Ion terrain provider + +The `terrain` layer of the `cesium-ion` type enables the use of Cesium Ion terrain format-compliant services (i.e., Cesium Ion resources). The options attribute allows for the configuration and access of Ion resources and their associated assets. + +```json +{ + "type": "terrain", + "provider": "cesium-ion", + "visibility": true, + "options": { + "assetId": "", // cesium ion asset id to be requested (mandatory) + "accessToken": "", // cesium access token to be used (mandatory) + "server": undefined, // resource from the Cesium ion API server. Defaults to https://api.cesium.com when unspecified + "credit": "" // optional, additional credit to be displayed along side credit and attribution from ion resource + } +} +``` + #### Elevation This layer provides information related to elevation based on a provided DTM layer. **It does not provide the terrain profile for 3D visualization**, see [terrain](#terrain) layer type for this feature. diff --git a/web/client/components/map/cesium/plugins/TerrainLayer.js b/web/client/components/map/cesium/plugins/TerrainLayer.js index 0a14e0e737..996d384aa7 100644 --- a/web/client/components/map/cesium/plugins/TerrainLayer.js +++ b/web/client/components/map/cesium/plugins/TerrainLayer.js @@ -26,6 +26,20 @@ function cesiumOptionsMapping(config) { }; } +function cesiumIonOptionsMapping(config) { + const options = config.options ?? {}; + return { + ...(options.assetId && { + url: Cesium.IonResource.fromAssetId(options.assetId, { + accessToken: options.accessToken, + server: options.server + }) + }), + credit: options.credit, + requestMetadata: options.requestMetadata + }; +} + const createLayer = (config, map) => { map.terrainProvider = undefined; let terrainProvider; @@ -42,6 +56,10 @@ const createLayer = (config, map) => { terrainProvider = new Cesium.EllipsoidTerrainProvider(); break; } + case 'cesium-ion': { + terrainProvider = new Cesium.CesiumTerrainProvider(cesiumIonOptionsMapping(config)); + break; + } default: terrainProvider = new Cesium.EllipsoidTerrainProvider(); break; @@ -61,7 +79,8 @@ const createLayer = (config, map) => { const updateLayer = (layer, newOptions, oldOptions, map) => { if (newOptions.securityToken !== oldOptions.securityToken || oldOptions.credits !== newOptions.credits - || oldOptions.provider !== newOptions.provider || oldOptions.forceProxy !== newOptions.forceProxy) { + || oldOptions.provider !== newOptions.provider + || oldOptions.forceProxy !== newOptions.forceProxy) { return createLayer(newOptions, map); } return null;