Interactive interface for browsing global, full-resolution satellite imagery
WV-2465 (#3998)
Jason Kent6e9eba7a912f
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.jsindex 99c5db182..43f073adc 100644--- a/web/js/modules/vector-styles/selectors.js+++ b/web/js/modules/vector-styles/selectors.js@@ -16,11 +16,27 @@ import {} from '../layers/selectors';/**- * Gets a single colormap (entries / legend combo)+ * Get OpenLayers layers from state that were created from WV vector+ * layer definiteions. NOTE: This currently also will include the associate WMS+ * breakpoint layers as well.*+ * @param {*} state+ * @returns+ */+export function getVectorLayers(state) {+ const { map: { ui: { selected } } } = state;+ const layerGroups = selected.getLayers().getArray();+ return layerGroups.reduce((prev, layerGroup) => {+ const isVector = lodashGet(layerGroup, 'wv.def.type') === 'vector';+ if (!isVector) return prev;+ const layers = layerGroup.getLayersArray ? layerGroup.getLayersArray() : layerGroup;+ return [...prev, ...layers];+ }, []);+}++/**+ * Gets a single colormap (entries / legend combo)*- * @method get- * @static* @param str {string} The ID of the layer* @param number {Number} The index of the colormap for this layer, default 0* object.diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.jsindex c6cee8530..beb0fc288 100644--- a/web/js/modules/vector-styles/util.js+++ b/web/js/modules/vector-styles/util.js@@ -8,7 +8,7 @@ import {import {Stroke, Style, Fill, Circle,} from 'ol/style';-import { setStyleFunction } from './selectors';+import { getVectorLayers, setStyleFunction } from './selectors';import { isFromActiveCompareRegion } from '../compare/util';export function getVectorStyleAttributeArray(layer) {@@ -317,24 +317,20 @@ export function onMapClickGetVectorFeatures(pixels, map, state, swipeOffset) {}export function updateVectorSelection(selectionObj, lastSelection, layers, type, state) {- const { config: { vectorStyles }, map: { ui: { selected } } } = state;- const layerGroups = selected.getLayers().getArray();- let olLayers = [];- layerGroups.forEach((group) => {- olLayers = [...olLayers, ...group.getLayers().getArray()];- });+ const { config: { vectorStyles } } = state;+ const vectorLayers = getVectorLayers(state);for (const [key] of Object.entries(selectionObj)) {const def = lodashFind(layers, { id: key });if (!def) return;- const olLayer = olLayers.find((layer) => layer.wv.id === key);+ const olLayer = vectorLayers.find((layer) => layer.wv.id === key);setStyleFunction(def, def.vectorStyle.id, vectorStyles, olLayer, state);if (lastSelection[key]) delete lastSelection[key];}for (const [key] of Object.entries(lastSelection)) {const def = lodashFind(layers, { id: key });if (!def) return;- const olLayer = olLayers.find((layer) => layer.wv.id === key);+ const olLayer = vectorLayers.find((layer) => layer.wv.id === key);setStyleFunction(def, def.vectorStyle.id, vectorStyles, olLayer, state);}}