Interactive interface for browsing global, full-resolution satellite imagery
Added useRef for updated layer list (#5832)
christof-wittreich491027d7a2b7
diff --git a/web/js/containers/tour.js b/web/js/containers/tour.jsindex ff497e871..dbdb40a7d 100644--- a/web/js/containers/tour.js+++ b/web/js/containers/tour.js@@ -534,7 +534,7 @@ const mapDispatchToProps = (dispatch) => ({) {layers = layersParse12(parameters.l, config);if (parameters.l1 && hasCustomTypePalette(parameters.l1)) {- layers.push(layersParse12(parameters.l1, config));+ layers.push(...layersParse12(parameters.l1, config));}layers = uniqBy(layers, 'id');diff --git a/web/js/mapUI/components/update-projection/updateProjection.js b/web/js/mapUI/components/update-projection/updateProjection.jsindex ba200ee3c..13caf5914 100644--- a/web/js/mapUI/components/update-projection/updateProjection.js+++ b/web/js/mapUI/components/update-projection/updateProjection.js@@ -1,4 +1,4 @@-import { useEffect, useState } from 'react';+import { useEffect, useState, useRef } from 'react';import PropTypes from 'prop-types';import { connect } from 'react-redux';import OlLayerGroup from 'ol/layer/Group';@@ -54,6 +54,12 @@ function UpdateProjection(props) {requestPalette,} = props;+ const layerStateRef = useRef(layerState);++ useEffect(() => {+ layerStateRef.current = layerState;+ }, [layerState]);+/*** Remove Layers from map*@@ -124,9 +130,9 @@ function UpdateProjection(props) {compareMapUi.destroy();}clearLayers(saveCache);- const defs = getLayers(layerState, { reverse: true });+ const defs = getLayers(layerStateRef.current, { reverse: true });const layerPromises = defs.map((def) => {- const options = getGranuleOptions(layerState, def, compare.activeString, granuleOptions);+ const options = getGranuleOptions(layerStateRef.current, def, compare.activeString, granuleOptions);return createLayer(def, options);});const layerResults = await Promise.allSettled(layerPromises);@@ -138,7 +144,7 @@ function UpdateProjection(props) {stateArray.reverse(); // Set Layer order based on active A|B group}clearLayers(saveCache);- const stateArrayGroups = stateArray.map(async (arr) => getCompareLayerGroup(arr, layerState, granuleOptions));+ const stateArrayGroups = stateArray.map(async (arr) => getCompareLayerGroup(arr, layerStateRef.current, granuleOptions));const compareLayerGroups = await Promise.all(stateArrayGroups);mapUI?.setLayers(compareLayerGroups);compareMapUi.create(mapUI, compare.mode);