diff --git a/src/js/models/maps/assets/Cesium3DTileset.js b/src/js/models/maps/assets/Cesium3DTileset.js index f8f9c0021..980ee3d44 100644 --- a/src/js/models/maps/assets/Cesium3DTileset.js +++ b/src/js/models/maps/assets/Cesium3DTileset.js @@ -126,7 +126,7 @@ define( try { var model = this; - var cesiumOptions = model.get('cesiumOptions') + var cesiumOptions = this.getCesiumOptions(); var cesiumModel = null // If the cesium model already exists, don't create it again unless specified @@ -183,7 +183,7 @@ define( setCesiumURL: function () { try { - var cesiumOptions = this.get('cesiumOptions') + var cesiumOptions = this.getCesiumOptions(); // Set the asset URL if this is a Cesium Ion 3D tileset or terrain if (cesiumOptions && cesiumOptions.ionAssetId) { diff --git a/src/js/models/maps/assets/CesiumGeohash.js b/src/js/models/maps/assets/CesiumGeohash.js index 61b627e65..c07e8e72c 100644 --- a/src/js/models/maps/assets/CesiumGeohash.js +++ b/src/js/models/maps/assets/CesiumGeohash.js @@ -269,7 +269,7 @@ define([ return; } // Set the GeoJSON representing geohashes on the model - const cesiumOptions = model.get("cesiumOptions"); + const cesiumOptions = this.getCesiumOptions(); const type = model.get("type"); const data = type === "geojson" ? this.getGeoJSON() : this.getCZML(); cesiumOptions["data"] = data; diff --git a/src/js/models/maps/assets/CesiumImagery.js b/src/js/models/maps/assets/CesiumImagery.js index 6227a667e..855addef4 100644 --- a/src/js/models/maps/assets/CesiumImagery.js +++ b/src/js/models/maps/assets/CesiumImagery.js @@ -109,11 +109,8 @@ define( this.getThumbnail(); } - catch (error) { - console.log( - 'There was an error initializing a CesiumImagery model' + - '. Error details: ' + error - ); + catch (e) { + console.log('Error initializing a CesiumImagery model: ', e); } }, @@ -196,7 +193,7 @@ define( createCesiumModel: function (recreate = false) { var model = this; - var cesiumOptions = this.get('cesiumOptions'); + const cesiumOptions = this.getCesiumOptions(); var type = this.get('type') var providerFunction = Cesium[type] diff --git a/src/js/models/maps/assets/CesiumTerrain.js b/src/js/models/maps/assets/CesiumTerrain.js index 261d321fa..d243bfed4 100644 --- a/src/js/models/maps/assets/CesiumTerrain.js +++ b/src/js/models/maps/assets/CesiumTerrain.js @@ -104,7 +104,7 @@ define( createCesiumModel: function (recreate = false) { var model = this; - var cesiumOptions = this.get('cesiumOptions'); + var cesiumOptions = model.getCesiumOptions(); var type = this.get('type') var terrainFunction = Cesium[type] @@ -145,7 +145,7 @@ define( setCesiumURL: function () { try { - var cesiumOptions = this.get('cesiumOptions') + var cesiumOptions = this.getCesiumOptions(); // Set the asset URL if this is a Cesium Ion 3D tileset or terrain if (cesiumOptions && cesiumOptions.ionAssetId) { diff --git a/src/js/models/maps/assets/CesiumVectorData.js b/src/js/models/maps/assets/CesiumVectorData.js index 1c7b9a265..fee95fc5b 100644 --- a/src/js/models/maps/assets/CesiumVectorData.js +++ b/src/js/models/maps/assets/CesiumVectorData.js @@ -161,7 +161,7 @@ define( try { const model = this; - const cesiumOptions = model.get('cesiumOptions') + const cesiumOptions = this.getCesiumOptions(); const type = model.get('type') const label = model.get('label') || '' const dataSourceFunction = Cesium[type] diff --git a/src/js/models/maps/assets/MapAsset.js b/src/js/models/maps/assets/MapAsset.js index 14029a89f..5476b60a8 100644 --- a/src/js/models/maps/assets/MapAsset.js +++ b/src/js/models/maps/assets/MapAsset.js @@ -316,6 +316,8 @@ define( if (!assetConfig || typeof assetConfig !== 'object') { assetConfig = {} + } else { + assetConfig = JSON.parse(JSON.stringify(assetConfig)) } // Set the color palette @@ -379,6 +381,20 @@ define( } }, + /** + * Get the asset config's cesiumOptions, if it has any. This will return + * a copy of the cesiumOptions object, so that changes made to the + * returned object will not affect the original cesiumOptions object. + * @returns {Object} A copy of the cesiumOptions object, or null if there + * are no cesiumOptions. + * @since x.x.x + */ + getCesiumOptions: function () { + const cesiumOptions = this.get('cesiumOptions') + if (!cesiumOptions) { return null } + return JSON.parse(JSON.stringify(cesiumOptions)) + }, + /** * Given a feature object from a Feature model, checks if it is part of the * selectedFeatures collection. See featureObject property from