feat(windkarte): Legend-Toggle — Status ein-/ausblendbar per Klick
Klick auf Legendenitem blendet den Status aus (opacity 0, kein Klick, kein Hover). Panel schließt sich wenn der Status des gewählten Gebiets ausgeblendet wird. Visuell: opacity + line-through auf versteckten Items. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,13 +8,37 @@
|
||||
onselect,
|
||||
onready = null,
|
||||
initialGebietsNr = null,
|
||||
hiddenStatuses = [],
|
||||
}: {
|
||||
areas: WindArea[];
|
||||
onselect: (area: WindArea | null, center: [number, number] | null) => void;
|
||||
onready?: ((ctrl: { reset: () => void }) => void) | null;
|
||||
initialGebietsNr?: string | null;
|
||||
hiddenStatuses?: string[];
|
||||
} = $props();
|
||||
|
||||
// Mirror prop into plain variable so Leaflet event handlers read current value.
|
||||
let _hidden: string[] = [];
|
||||
$effect(() => {
|
||||
_hidden = hiddenStatuses;
|
||||
if (!geojsonLayer) return;
|
||||
restyleAll(selectedSlug);
|
||||
// Deselect if selected area's status was just hidden.
|
||||
if (selectedSlug) {
|
||||
geojsonLayer.eachLayer((l) => {
|
||||
const f = (l as import("leaflet").Path & { feature?: GeoJSON.Feature }).feature;
|
||||
if (f?.properties?.name === selectedSlug) {
|
||||
const s = f.properties?.status ?? "rechtskraeftig";
|
||||
if (_hidden.includes(s)) {
|
||||
selectedSlug = null;
|
||||
onselect(null, null);
|
||||
bufferLayer?.clearLayers();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let mapEl: HTMLDivElement;
|
||||
let map: import("leaflet").Map | null = null;
|
||||
let bufferLayer: import("leaflet").LayerGroup | null = null;
|
||||
@@ -46,7 +70,11 @@
|
||||
const f = (l as import("leaflet").Path & { feature?: GeoJSON.Feature }).feature;
|
||||
if (!f) return;
|
||||
const s = f.properties?.status ?? "rechtskraeftig";
|
||||
(l as import("leaflet").Path).setStyle(style(s, f.properties?.name === sel));
|
||||
if (_hidden.includes(s)) {
|
||||
(l as import("leaflet").Path).setStyle({ opacity: 0, fillOpacity: 0, weight: 0 });
|
||||
} else {
|
||||
(l as import("leaflet").Path).setStyle(style(s, f.properties?.name === sel));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,19 +196,23 @@
|
||||
|
||||
// Hover highlight
|
||||
layer.on("mouseover", () => {
|
||||
const s = feature.properties?.status ?? "rechtskraeftig";
|
||||
if (_hidden.includes(s)) return;
|
||||
if (feature.properties?.name !== selectedSlug) {
|
||||
const s = feature.properties?.status ?? "rechtskraeftig";
|
||||
(layer as import("leaflet").Path).setStyle(style(s, false, true));
|
||||
}
|
||||
});
|
||||
layer.on("mouseout", () => {
|
||||
const s = feature.properties?.status ?? "rechtskraeftig";
|
||||
if (_hidden.includes(s)) return;
|
||||
if (feature.properties?.name !== selectedSlug) {
|
||||
const s = feature.properties?.status ?? "rechtskraeftig";
|
||||
(layer as import("leaflet").Path).setStyle(style(s, false, false));
|
||||
}
|
||||
});
|
||||
|
||||
layer.on("click", async (e) => {
|
||||
const s = feature.properties?.status ?? "rechtskraeftig";
|
||||
if (_hidden.includes(s)) return;
|
||||
L.DomEvent.stopPropagation(e);
|
||||
await selectFeature(L, feature, layer, area);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user