From 8d3a620275c482658b64a8f6ab80e1a268b2d6b3 Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 25 Apr 2026 21:46:36 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Karte-Scan=20wenn=20Diary-Karte=20vorher?= =?UTF-8?q?=20ge=C3=B6ffnet=20=E2=80=94=20SW=20by-v406?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diary.js lädt Leaflet ohne MarkerCluster. Wenn der User zuerst die Diary-Karte öffnet, findet _loadLeaflet() in map.js ein gesetztes window.L und überspringt das Laden komplett — inklusive MarkerCluster. L.markerClusterGroup() schlägt dann still fehl (catch { return 0; }), und alle OSM-Layer zeigen 0 Marker. Fix: Leaflet-Basis und MarkerCluster separat prüfen: - window.L fehlt → lade Leaflet-Basis - window.L.markerClusterGroup fehlt → lade MarkerCluster --- backend/static/js/app.js | 2 +- backend/static/js/pages/map.js | 48 ++++++++++++++++++---------------- backend/static/sw.js | 2 +- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 9837de2..d7a0b32 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '385'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '386'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const App = (() => { diff --git a/backend/static/js/pages/map.js b/backend/static/js/pages/map.js index 3c5fad5..67b6e5a 100644 --- a/backend/static/js/pages/map.js +++ b/backend/static/js/pages/map.js @@ -286,33 +286,35 @@ window.Page_map = (() => { // Leaflet + MarkerCluster laden // ---------------------------------------------------------- async function _loadLeaflet() { - if (_leafletLoaded || window.L) { _leafletLoaded = true; return; } + if (_leafletLoaded) return; - // Leaflet CSS - const lCss = document.createElement('link'); - lCss.rel = 'stylesheet'; lCss.href = '/css/leaflet.css'; - document.head.appendChild(lCss); + // Leaflet-Basis: nur laden wenn noch nicht vorhanden (diary.js kann es vorgeladen haben) + if (!window.L) { + const lCss = document.createElement('link'); + lCss.rel = 'stylesheet'; lCss.href = '/css/leaflet.css'; + document.head.appendChild(lCss); - // Leaflet JS - await new Promise(resolve => { - const s = document.createElement('script'); - s.src = '/js/leaflet.js'; s.onload = resolve; - document.head.appendChild(s); - }); + await new Promise(resolve => { + const s = document.createElement('script'); + s.src = '/js/leaflet.js'; s.onload = resolve; + document.head.appendChild(s); + }); + } - // MarkerCluster CSS - ['MarkerCluster.css', 'MarkerCluster.Default.css'].forEach(f => { - const l = document.createElement('link'); - l.rel = 'stylesheet'; l.href = `/css/${f}`; - document.head.appendChild(l); - }); + // MarkerCluster: separat prüfen — diary.js lädt Leaflet ohne MarkerCluster + if (!window.L.markerClusterGroup) { + ['MarkerCluster.css', 'MarkerCluster.Default.css'].forEach(f => { + const l = document.createElement('link'); + l.rel = 'stylesheet'; l.href = `/css/${f}`; + document.head.appendChild(l); + }); - // MarkerCluster JS - await new Promise(resolve => { - const s = document.createElement('script'); - s.src = '/js/leaflet.markercluster.js'; s.onload = resolve; - document.head.appendChild(s); - }); + await new Promise(resolve => { + const s = document.createElement('script'); + s.src = '/js/leaflet.markercluster.js'; s.onload = resolve; + document.head.appendChild(s); + }); + } _leafletLoaded = true; } diff --git a/backend/static/sw.js b/backend/static/sw.js index 836ef26..ca5421c 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v405'; +const CACHE_VERSION = 'by-v406'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten