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 });