From 66cbe33a6b846e146a058938117884d531c22aba Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 6 Apr 2026 19:06:55 +0200 Subject: [PATCH] fix: Karte zeigt Iran sofort, Legende nicht mehr doppelt - dataLoaded Flag verhindert Map-Update bevor Daten geladen sind - legendControl wird korrekt gespeichert und beim Wechsel entfernt Co-Authored-By: Claude Opus 4.6 (1M context) --- vorschau/js/app.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vorschau/js/app.js b/vorschau/js/app.js index f3319a4..d32beea 100644 --- a/vorschau/js/app.js +++ b/vorschau/js/app.js @@ -76,6 +76,7 @@ var markerLayer = null; var legendControl = null; var lageData = {}; + var dataLoaded = false; /* ==================== 3D CAROUSEL ==================== */ var cards = document.querySelectorAll('.carousel-card'); @@ -94,7 +95,8 @@ dots.forEach(function (dot, i) { dot.classList.toggle('active', i === idx); }); - // Update map based on active Lage + // Update map based on active Lage (only after data loaded) + if (!dataLoaded) return; var lage = cards[idx].getAttribute('data-lage'); var mapSection = document.getElementById('map-section'); if (lage && lageData[lage]) { @@ -209,7 +211,10 @@ function mdToHtml(md) { locations: data.locations || [], category_labels: data.category_labels || {} }; + dataLoaded = true; createMap(); + var mapSection = document.getElementById('map-section'); + if (mapSection) mapSection.classList.remove('map-hidden'); showMarkers(data.locations || [], data.category_labels || {}); }) .catch(function () { @@ -310,7 +315,8 @@ function mdToHtml(md) { div.innerHTML = html; return div; }; - legend.addTo(mapInstance); + legendControl = legend; + legendControl.addTo(mapInstance); if (bounds.length > 0) { mapInstance.fitBounds(bounds, { padding: [30, 30], maxZoom: 7 });