From 4d5b06ce9b310d59eb26a701363a4267ffb0eb75 Mon Sep 17 00:00:00 2001 From: Lisa Stillwell Date: Tue, 15 Oct 2024 16:44:50 -0400 Subject: [PATCH 1/4] #295 changes to move layer opacity to settings --- src/components/map/adcirc-raster-layer.js | 24 +++++++++++++-- src/components/map/default-layers.js | 4 +-- .../trays/layers/layer-card-actions.js | 10 +++---- .../trays/settings/colormaps/style-edit.js | 30 +++++++++++++++++++ src/context/settings.js | 22 ++++++++++++++ 5 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/components/map/adcirc-raster-layer.js b/src/components/map/adcirc-raster-layer.js index 9a405c4f..bbad1d90 100644 --- a/src/components/map/adcirc-raster-layer.js +++ b/src/components/map/adcirc-raster-layer.js @@ -4,6 +4,10 @@ import SldStyleParser from 'geostyler-sld-parser'; import { getNamespacedEnvParam, restoreColorMapType } from '@utils/map-utils'; import { useSettings } from '@context'; +const MAXELE = 'maxele'; +const MAXWVEL = 'maxwvel'; +const SWAN = 'swan'; + export const AdcircRasterLayer = (layer) => { const sldParser = new SldStyleParser(); const gs_wfs_url = `${ getNamespacedEnvParam('REACT_APP_GS_DATA_URL') }`; @@ -11,11 +15,13 @@ export const AdcircRasterLayer = (layer) => { const { mapStyle, + layerOpacity, } = useSettings(); const [currentStyle, setCurrentStyle] = useState(""); + const [productType, setProductType] = useState(""); - useEffect(() => { + useEffect(() => { if(layer.layer.properties) { let style = ""; switch(layer.layer.properties.product_type) { @@ -42,7 +48,19 @@ export const AdcircRasterLayer = (layer) => { }); }); } - }, [mapStyle]); + }, [mapStyle]); + + useEffect(() => { + // get current product layer in order to set opacity + if (layer.layer.properties.product_type.includes(MAXWVEL)) + setProductType(MAXWVEL); + else + if (layer.layer.properties.product_type.includes(SWAN)) + setProductType(SWAN); + else + setProductType(MAXELE); + }, [layerOpacity]); + // memorizing this params object prevents // that map flicker on state changes. @@ -57,7 +75,7 @@ export const AdcircRasterLayer = (layer) => { url={gs_wms_url} layers={layer.layer.layers} params={wmsLayerParams} - opacity={layer.layer.state.opacity} + opacity={layerOpacity[productType].current} /> ); diff --git a/src/components/map/default-layers.js b/src/components/map/default-layers.js index 92748367..396520f6 100644 --- a/src/components/map/default-layers.js +++ b/src/components/map/default-layers.js @@ -13,14 +13,14 @@ const newLayerDefaultState = (layer) => { if (['obs', 'maxele63'].includes(product_type)) { return ({ visible: true, - opacity: 1.0, + //opacity: 1.0, style: "", }); } return ({ visible: false, - opacity: 1.0, + //opacity: 1.0, style: "", }); }; diff --git a/src/components/trays/layers/layer-card-actions.js b/src/components/trays/layers/layer-card-actions.js index 09d0a3d7..1c097c13 100644 --- a/src/components/trays/layers/layer-card-actions.js +++ b/src/components/trays/layers/layer-card-actions.js @@ -29,12 +29,12 @@ export const LayerActions = ({ layer }) => { justifyContent="space-between" > - +{/* Appearance - + */} @@ -44,7 +44,7 @@ export const LayerActions = ({ layer }) => { - { alignItems: 'center', }}>Coming soon... - + */} - + { const { mapStyle, + layerOpacity, } = useSettings(); const [colormap, setColormap] = useState(); @@ -183,6 +186,20 @@ export const StyleEditor = () => { }); }; + const getProductType = () => { + let type = MAXELE; + + if (style) { + if (style.includes(MAXWVEL)) type = MAXWVEL; + else + if (style.includes(SWAN)) type = SWAN; + } + + return type; + } + + const productType = getProductType(); + return ( {colormap && + + Opacity + layerOpacity[productType].set(newValue) } + /> + + } ); From 844bcbc7ebcec07cdffaa03d2a2d01c8f1e7d5c8 Mon Sep 17 00:00:00 2001 From: Lisa Stillwell Date: Fri, 18 Oct 2024 14:18:23 -0400 Subject: [PATCH 4/4] added space for LayerOpacity --- src/components/trays/settings/colormaps/style-edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/trays/settings/colormaps/style-edit.js b/src/components/trays/settings/colormaps/style-edit.js index ddf8cb9b..aa066d73 100644 --- a/src/components/trays/settings/colormaps/style-edit.js +++ b/src/components/trays/settings/colormaps/style-edit.js @@ -215,7 +215,7 @@ export const StyleEditor = () => { - LayerOpacity + Layer Opacity