diff --git a/src/app.js b/src/app.js
index 4425dab2..eae1e6ff 100644
--- a/src/app.js
+++ b/src/app.js
@@ -4,6 +4,7 @@ import { ObservationDialog } from "@components/dialog/observation-dialog";
import { useLayers } from '@context';
import { Sidebar } from '@components/sidebar';
import { ControlPanel } from '@components/control-panel';
+import { MapLegend } from '@components/legend';
export const App = () => {
// install the selected observation list from the layer context
@@ -23,6 +24,7 @@ export const App = () => {
+
);
};
diff --git a/src/components/legend/index.js b/src/components/legend/index.js
new file mode 100644
index 00000000..74075732
--- /dev/null
+++ b/src/components/legend/index.js
@@ -0,0 +1 @@
+export * from './legend';
\ No newline at end of file
diff --git a/src/components/legend/legend.js b/src/components/legend/legend.js
new file mode 100644
index 00000000..ee579130
--- /dev/null
+++ b/src/components/legend/legend.js
@@ -0,0 +1,89 @@
+import React from 'react';
+import { Avatar, Box, Card, Stack } from '@mui/joy';
+import { useLayers } from '@context';
+
+export const MapLegend = () => {
+
+ // set correct map styles for layer name
+ // may want to move this somewhere else later
+ // for the implementation of user designed styles
+ const layerStyles = {
+ 'maxele63': 'maxele_style_v3ui',
+ 'maxwvel63': 'maxwvel_style_v3ui',
+ 'swan_HS_max63': 'swan_style_v3ui',
+ 'maxinundepth63': 'maxele_style_v3ui',
+ 'maxele_level_downscaled_epsg4326': 'maxele_style_v3ui',
+ 'hec_ras_water_surface': 'maxele_style_v3ui'
+ };
+
+ const {
+ defaultModelLayers,
+ layerTypes,
+ } = useLayers();
+ let legendVisibilty = "hidden";
+
+ let LegendIcon = layerTypes['maxele63'].icon;
+ let legendUrl = '';
+
+ // need to find the top-most layer that is currently visible
+ const legendLayer = defaultModelLayers.find(layer => layer.state.visible && layer.properties.product_type !== 'obs');
+ if (legendLayer) {
+ LegendIcon = layerTypes[legendLayer.properties.product_type].icon;
+
+ // now build appropriate url for retrieving the legend graphic
+ const workspace = legendLayer.layers.split(':')[0];
+ const layerName = legendLayer.layers.split(':')[1];
+ const style = layerStyles[layerName.substring(layerName.indexOf('_')+1)];
+
+ legendUrl = `${process.env.REACT_APP_GS_DATA_URL}` +
+ workspace + "/" +
+ "ows?service=WMS&request=GetLegendGraphic&TRANSPARENT=TRUE&LEGEND_OPTIONS=layout:verticle&format=image%2Fpng&width=20&height=20&layer=" +
+ layerName +
+ "&style=" + style;
+
+ // all set - show the legend
+ legendVisibilty = "visible";
+
+ }
+ else {
+ // if no layers turned on, hide legend
+ legendVisibilty = "hidden";
+ }
+
+ return (
+
+
+
+
+
+
+
+
+ );
+};
\ No newline at end of file