Add Legend to map

This commit is contained in:
2026-01-07 19:43:14 +01:00
parent 81d63ae727
commit 4619970bd2

View File

@@ -41,6 +41,9 @@ server <- function(input, output, session) {
mapproxy <- leafletProxy("hhmap")
clearGroup(mapproxy, "selected")
clearGroup(mapproxy, "layer_heatmap")
# Entfernt eine eventuell existierende Legende vom vorherigen Durchlauf
removeControl(mapproxy, "heatmap_legend")
if (heatmap != "") {
hideGroup(mapproxy, "layer_bezirke")
hideGroup(mapproxy, "layer_stadtteile")
@@ -68,6 +71,14 @@ server <- function(input, output, session) {
weight = 3,
fillOpacity = 0.8
)
# Legende hinzufügen
addLegend(mapproxy,
pal = pal,
values = heatmap_polygons$intensity,
title = paste("Intensität:", heatmap),
position = "bottomright",
layerId = "heatmap_legend" # Wichtig zum gezielten Entfernen
)
#---------------------
} else {
if (maptype == "Bezirke"){