fix: OrganisationsMap erst bei Klick interaktiv, kein Page-Scroll-Hijack
Initial Drag/Zoom deaktiviert. Overlay 'Karte aktivieren' freigibt Interaktion. Marker-Klick aktiviert automatisch mit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,9 +24,19 @@
|
||||
let mapEl: HTMLDivElement;
|
||||
let map: import("leaflet").Map | null = null;
|
||||
let selectedOrg = $state<OrganisationEntry | null>(null);
|
||||
let mapActive = $state(false);
|
||||
// Keep reference to highlight active marker
|
||||
let activeMarker: import("leaflet").CircleMarker | null = null;
|
||||
|
||||
function activateMap() {
|
||||
if (mapActive || !map) return;
|
||||
mapActive = true;
|
||||
map.scrollWheelZoom.enable();
|
||||
map.dragging.enable();
|
||||
map.touchZoom.enable();
|
||||
map.doubleClickZoom.enable();
|
||||
}
|
||||
|
||||
const descriptionHtml = $derived(
|
||||
selectedOrg?.description
|
||||
? (marked.parse(selectedOrg.description) as string)
|
||||
@@ -60,7 +70,13 @@
|
||||
onMount(async () => {
|
||||
const L = (await import("leaflet")).default;
|
||||
|
||||
map = L.map(mapEl, { zoomControl: true });
|
||||
map = L.map(mapEl, {
|
||||
zoomControl: true,
|
||||
scrollWheelZoom: false,
|
||||
dragging: false,
|
||||
touchZoom: false,
|
||||
doubleClickZoom: false,
|
||||
});
|
||||
|
||||
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
|
||||
@@ -85,6 +101,7 @@
|
||||
})
|
||||
.addTo(map!)
|
||||
.on("click", () => {
|
||||
activateMap();
|
||||
if (activeMarker && activeMarker !== marker) {
|
||||
activeMarker.setStyle({ fillColor: "#3d6b4f", radius: 8 });
|
||||
}
|
||||
@@ -119,6 +136,20 @@
|
||||
<!-- Leaflet map fills the container -->
|
||||
<div bind:this={mapEl} class="absolute inset-0"></div>
|
||||
|
||||
{#if !mapActive}
|
||||
<button
|
||||
type="button"
|
||||
onclick={activateMap}
|
||||
class="absolute inset-0 z-[500] flex cursor-pointer items-center justify-center border-0 bg-black/15 p-0 transition-colors hover:bg-black/25"
|
||||
aria-label="Karte aktivieren"
|
||||
>
|
||||
<span class="flex items-center gap-2 rounded-md bg-white/95 px-3 py-1.5 text-sm font-medium text-stein-800 shadow-md">
|
||||
<Icon icon="mdi:cursor-default-click-outline" class="size-4" />
|
||||
Karte aktivieren
|
||||
</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<!-- Detail panel slides in from right (desktop) / bottom (mobile) -->
|
||||
{#if selectedOrg}
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user