Skip to content

Commit bd8635b

Browse files
Merge pull request #103 from geoCML/webmap-legend
Add legend to web map
2 parents cb6ac4b + e6c428f commit bd8635b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { useSelector } from "react-redux";
2+
3+
export function Legend() {
4+
const layers = useSelector((state) => state.app.layers);
5+
6+
return (
7+
<div
8+
id="legend"
9+
className="position-absolute bg-light rounded p-2 overflow-auto"
10+
style={{
11+
bottom: "25px",
12+
right: 0,
13+
zIndex: 99,
14+
maxHeight: "40%",
15+
maxWidth: "20%",
16+
}}
17+
>
18+
<img src={`/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERTITLE=true&RULELABEL=true&LAYERS=${layers.map((layer) => {
19+
return layer.name
20+
}).join(",")}`} alt="Legend"/>
21+
</div>
22+
);
23+
}

build-resources/geocml-server/portal/src/components/WebMap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useEffect, useRef } from "react";
22
import { useDispatch, useSelector } from "react-redux";
33
import { LayersPane } from "./LayersPane";
4+
import { Legend } from "./Legend";
45
import { hideWebMap } from "../app-slice";
56

67
const L = require("leaflet");
@@ -67,7 +68,8 @@ export function WebMap() {
6768
</div>
6869

6970
<LayersPane />
70-
</div>
71+
<Legend />
72+
</div>
7173
);
7274
}
7375
}

0 commit comments

Comments
 (0)