From c02c1fb568933631b47e0e8c678ee90c07e40123 Mon Sep 17 00:00:00 2001 From: Nishit Suwal <81785002+NSUWAL123@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:18:15 +0545 Subject: [PATCH] feat: project info legend (#1017) * feat (projectInfo): map - legend added to map * fix (vectorLayer) - default style overriding setStyle if setStyle supplied stopped * fix (projectInfo): legend - legend header changed --- .../OpenLayersComponent/Layers/VectorLayer.js | 4 +- .../ProjectInfo/ProjectInfoMapLegend.jsx | 38 +++++++++++++++++++ .../components/ProjectInfo/ProjectInfomap.jsx | 17 ++++++++- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/frontend/src/components/ProjectInfo/ProjectInfoMapLegend.jsx diff --git a/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js b/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js index 4a1efb3e86..c84f0b7671 100644 --- a/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js +++ b/src/frontend/src/components/MapComponent/OpenLayersComponent/Layers/VectorLayer.js @@ -190,7 +190,7 @@ const VectorLayer = ({ }, [map, vectorLayer, getTaskStatusStyle]); useEffect(() => { - if (!vectorLayer || !style.visibleOnMap) return; + if (!vectorLayer || !style.visibleOnMap || setStyle) return; vectorLayer.setStyle((feature, resolution) => [ new Style({ image: new CircleStyle({ @@ -207,7 +207,7 @@ const VectorLayer = ({ }), getStyles({ style, feature, resolution }), ]); - }, [vectorLayer, style]); + }, [vectorLayer, style, setStyle]); useEffect(() => { if (!vectorLayer) return; diff --git a/src/frontend/src/components/ProjectInfo/ProjectInfoMapLegend.jsx b/src/frontend/src/components/ProjectInfo/ProjectInfoMapLegend.jsx new file mode 100644 index 0000000000..088f83da32 --- /dev/null +++ b/src/frontend/src/components/ProjectInfo/ProjectInfoMapLegend.jsx @@ -0,0 +1,38 @@ +import React from 'react'; + +const colorCodes = [ + { color: '#0062AC', min: 130, max: 160 }, + { color: '#4A90D9', min: 100, max: 130 }, + { color: '#7CB2E8', min: 50, max: 100 }, + { color: '#A9D2F3', min: 10, max: 50 }, + { color: '#FF4538', min: 0, max: 0 }, +]; + +const LegendListItem = ({ code }) => ( +
+ {code.min} - {code.max} +
+ ) : ( +{code.min}
+ )} ++ No. of Submissions +
+ } + onToggle={() => {}} + className="fmtm-py-0 !fmtm-pb-0 fmtm-rounded-lg hover:fmtm-bg-gray-50" + collapsed={true} + /> +