diff --git a/src/components/map/adcirc-raster-layer.js b/src/components/map/adcirc-raster-layer.js index cbd3d4b..8bd15ad 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, markClicked, restoreColorMapType } from '@utils/map-utils'; import { useLayers, 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,9 +15,11 @@ export const AdcircRasterLayer = (layer) => { const { mapStyle, + layerOpacity, } = useSettings(); const [currentStyle, setCurrentStyle] = useState(""); + const [productType, setProductType] = useState(""); useEffect(() => { if(layer.layer.properties) { @@ -44,6 +50,18 @@ export const AdcircRasterLayer = (layer) => { } }, [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]); + + // get the observation points selected, default layers and alert message from state const { setSelectedObservations, @@ -135,7 +153,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 9274836..396520f 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 09d0a3d..6fb80da 100644 --- a/src/components/trays/layers/layer-card-actions.js +++ b/src/components/trays/layers/layer-card-actions.js @@ -2,10 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Box, - FormControl, - FormLabel, ListItemDecorator, - Slider, Tab, TabList, Tabs, @@ -13,14 +10,10 @@ import { Stack, } from '@mui/joy'; import { - FormatPaint as AppearanceIcon, DataObject as MetadataIcon, } from '@mui/icons-material'; -import { useLayers, useSettings } from '@context'; export const LayerActions = ({ layer }) => { - const { darkMode } = useSettings(); - const { setLayerOpacity } = useLayers(); return ( @@ -29,12 +22,12 @@ export const LayerActions = ({ layer }) => { justifyContent="space-between" > - +{/* Appearance - + */} @@ -44,7 +37,7 @@ export const LayerActions = ({ layer }) => { - { alignItems: 'center', }}>Coming soon... - + */} - + { const { mapStyle, + layerOpacity, } = useSettings(); const [colormap, setColormap] = useState(); @@ -183,6 +187,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 && + + + Layer Opacity + layerOpacity[productType].set(newValue) } + /> + + + ColorMap + } ); diff --git a/src/components/trays/settings/index.js b/src/components/trays/settings/index.js index d6e07fa..fdbd58a 100644 --- a/src/components/trays/settings/index.js +++ b/src/components/trays/settings/index.js @@ -14,10 +14,10 @@ export const trayContents = () => ( Set/Unset Dark Mode - + Select a Basemap - + Edit ADCIRC Layer Colormaps diff --git a/src/context/settings.js b/src/context/settings.js index 7be554f..898ee85 100644 --- a/src/context/settings.js +++ b/src/context/settings.js @@ -32,6 +32,11 @@ export const SettingsProvider = ({ children }) => { const [storedMaxwvelStyle, setStoredMaxwvelStyle] = useLocalStorage('maxwvel', maxwvelStyle); const [storedSwanStyle, setStoredSwanStyle] = useLocalStorage('swan', swanStyle); + // opacity now handled at layer type level + const [storedMaxeleOpacity, setStoredMaxeleOpacity] = useLocalStorage('maxele_opacity', 1.0); + const [storedMaxwvelOpacity, setStoredMaxwvelOpacity] = useLocalStorage('maxwvel_opacity',1.0); + const [storedSwanOpacity, setStoredSwanOpacity] = useLocalStorage('swan_opacity',1.0); + return ( { } }, + + layerOpacity: { + maxele: { + current: storedMaxeleOpacity, + set: setStoredMaxeleOpacity, + }, + maxwvel: { + current: storedMaxwvelOpacity, + set: setStoredMaxwvelOpacity, + }, + swan: { + current: storedSwanOpacity, + set: setStoredSwanOpacity, + } + }, }}> { children }