Interactive interface for browsing global, full-resolution satellite imagery
Fix comparison feature breaking when two layers of the same type are loaded
ZachTRicea9b24a843ac8
diff --git a/web/js/components/tour/modal-tour-in-progress.js b/web/js/components/tour/modal-tour-in-progress.jsindex 45ae10574..24bda9a9e 100644--- a/web/js/components/tour/modal-tour-in-progress.js+++ b/web/js/components/tour/modal-tour-in-progress.js@@ -86,6 +86,10 @@ class ModalInProgress extends React.Component {var config = this.props.config;var models = this.props.models;+ // When the link is loaded properly, save the tour to URL+ models.tour.active = true;+ models.tour.select(this.props.currentStoryId);+googleTagManager.pushEvent({'event': 'tour_selected_story','story': {@@ -95,8 +99,9 @@ class ModalInProgress extends React.Component {}});- // Get current step link- currentStepLink = currentStory.steps[currentStepIndex]['stepLink'];+ // Get current step link + current tour parameter+ currentStepLink = currentStory.steps[currentStepIndex]['stepLink'] ++ '&tr=' + this.props.currentStoryId;// Get current step transistionstepTransition = currentStory.steps[currentStepIndex]['transition'];@@ -107,17 +112,17 @@ class ModalInProgress extends React.Component {}// TESTING HERE:- currentStepLink =- 'ca=false' +- '&cm=opacity' +- '&cv=80' +- '&p=geographic' +- '&l=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Combined_Value_Added_AOD,MODIS_Terra_Aerosol_Optical_Depth_3km,Reference_Labels(hidden),Reference_Features(hidden),Coastlines' +- '&l1=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),BlueMarble_NextGeneration,IMERG_Snow_Rate,IMERG_Rain_Rate' +- '&t=2018-09-06-T00%3A00%3A00Z' +- '&t1=2018-03-06-T00%3A00%3A00Z' +- '&z=2' +- '&v=-202.1385353269304,-23.272676762951903,67.8614646730696,108.6335732370481' ++ // currentStepLink =+ // 'ca=false' ++ // '&cm=opacity' ++ // '&cv=80' ++ // '&p=geographic' ++ // '&l=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Combined_Value_Added_AOD,MODIS_Terra_Aerosol_Optical_Depth_3km,Reference_Labels(hidden),Reference_Features(hidden),Coastlines' ++ // '&l1=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),BlueMarble_NextGeneration,IMERG_Snow_Rate,IMERG_Rain_Rate' ++ // '&t=2018-09-06-T00%3A00%3A00Z' ++ // '&t1=2018-03-06-T00%3A00%3A00Z' ++ // '&z=2' ++ // '&v=-202.1385353269304,-23.272676762951903,67.8614646730696,108.6335732370481' +// '&download=MOD04_3K' +// '&e=true' +// '&ab=on' +@@ -125,7 +130,7 @@ class ModalInProgress extends React.Component {// '&ae=2018-09-26T00%3A00%3A00Z' +// '&av=5' +// '&al=true' +- '';+ // '&tr=' + this.props.currentStoryId;// Create current and previous states from step linkscurrentState = util.fromQueryString(currentStepLink);@@ -187,21 +192,20 @@ class ModalInProgress extends React.Component {}}+ // LOAD: Comparison+ models.compare.load(currentState, errors);+// LOAD: Projectionmodels.proj.load(currentState, errors);- // LOAD: Palettes- palettes.loadCustom(config);-// LOAD: Layersmodels.layers.load(currentState, errors);- ui.map.reloadLayers();// LOAD: Date(s)models.date.load(currentState, errors);- // LOAD: Comparison- models.compare.load(currentState, errors);+ // LOAD: Palettes+ palettes.loadCustom(config);// LOAD: Animationif (!currentState.download) {diff --git a/web/js/components/tour/tour.js b/web/js/components/tour/tour.jsindex 54a58c8a9..efcef5359 100644--- a/web/js/components/tour/tour.js+++ b/web/js/components/tour/tour.js@@ -50,6 +50,9 @@ class Tour extends React.Component {this.setState({modalInProgress: !this.state.modalInProgress});+ // When tour is not in progress, remove from URL+ this.props.models.tour.active = false;+ this.props.models.tour.select(this.state.currentStoryId);this.toggleMetaLoaded();}diff --git a/web/js/layers/model.js b/web/js/layers/model.jsindex b255f939c..4b3d920b2 100644--- a/web/js/layers/model.js+++ b/web/js/layers/model.js@@ -270,7 +270,9 @@ export function layersModel(models, config) {}});}- // self.events.trigger('add', def, null, self[activeLayerString]);+ if (addType !== 'tour') {+ self.events.trigger('add', def, null, self[activeLayerString]);+ }self.events.trigger('change');return self[activeLayerString];};@@ -525,14 +527,15 @@ export function layersModel(models, config) {if (!lodashIsUndefined(state[obj.state])) {self.clear(models.proj.selected.id, obj.active);lodashEachRight(state[obj.state], function(layerDef) {+ let addType = null;+ let hidden = false;+ let opacity = 1.0;if (!config.layers[layerDef.id]) {errors.push({message: 'No such layer: ' + layerDef.id});return;}- var hidden = false;- var opacity = 1.0;lodashEach(layerDef.attributes, function(attr) {if (attr.id === 'hidden') {hidden = true;@@ -542,14 +545,17 @@ export function layersModel(models, config) {if (isNaN(opacity)) opacity = 0; // "opacity=0.0" is opacity in URL, resulting in NaN}});-+ if (state.tr && (state.ca || state.cm)) {+ addType = 'tour';+ }self[obj.active] = self.add(layerDef.id,{hidden: hidden,opacity: opacity},- obj.active+ obj.active,+ addType);});}diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 2c4bccdbc..e8b5ce774 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -87,11 +87,11 @@ export function mapui(models, config) {.on('opacity', updateOpacity);if (models.compare) {models.compare.events- .on('toggle', self.reloadLayers)- .on('mode', self.reloadLayers)+ .on('toggle', reloadLayers)+ .on('mode', reloadLayers).on('toggle-state', () => {if (models.compare.mode === 'spy') {- self.reloadLayers();+ reloadLayers();}});}@@ -122,7 +122,7 @@ export function mapui(models, config) {}self.selected = self.proj[models.proj.selected.id];var map = self.selected;- self.reloadLayers();+ reloadLayers();// Update the rotation buttons if polar projection to display correct valueif (@@ -236,14 +236,14 @@ export function mapui(models, config) {* get layers from models obj* and add each layer to the map*- * @method self.reloadLayers+ * @method reloadLayers* @static** @param {object} map - Openlayers Map obj** @returns {void}*/- self.reloadLayers = function(map) {+ var reloadLayers = function(map) {map = map || self.selected;var compareModel = models.compare;var layerGroupStr = models.layers.activeLayers;@@ -427,7 +427,6 @@ export function mapui(models, config) {activelayer.getLayers().insertAt(mapIndex, newLayer);compare.create(self.selected, models.compare.mode);} else {- console.log(self.selected.getLayers());self.selected.getLayers().insertAt(mapIndex, createLayer(def));}}@@ -471,7 +470,7 @@ export function mapui(models, config) {* @returns {void}*/var updateLayerOrder = function() {- self.reloadLayers();+ reloadLayers();};/*@@ -539,7 +538,7 @@ export function mapui(models, config) {* @todo Check if this function can be combined with updateLayerOrder*/var updateLookup = function(layerId) {- self.reloadLayers();+ reloadLayers();};self.getCustomLayerTimeout = function(layer) {diff --git a/web/js/tour/model.js b/web/js/tour/model.jsindex b8ee91e52..7477ec651 100644--- a/web/js/tour/model.js+++ b/web/js/tour/model.js@@ -2,9 +2,15 @@ import util from '../util/util';export function tourModel(config) {var self = {};+ self.active = false;self.selected = null;self.events = util.events();+ self.toggle = function() {+ self.active = !self.active;+ self.events.trigger('toggle');+ };+self.select = function (storyId) {var story = config.stories[storyId];if (!story) {@@ -19,7 +25,9 @@ export function tourModel(config) {};self.save = function (state) {- if (state.tr) {+ if (!self.active) {+ if (state.tr) delete state.tr;+ } else {state.tr = self.selected.id;}};