Leaflet lokal bundlen, kein CDN mehr

leaflet.js + leaflet.css lokal in static/, Attribution in CSS
auf display:none gesetzt. Loest CDN-SSL-Fehler + Attribution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rene 2026-04-12 18:11:37 +02:00
parent 2baba57941
commit 53b37e7c09
3 changed files with 673 additions and 15 deletions

File diff suppressed because one or more lines are too long

View file

@ -95,22 +95,22 @@ window.Page_poison = (() => {
async function _loadLeaflet() {
if (_leafletLoaded || window.L) { _leafletLoaded = true; return; }
// CSS laden und auf onload warten — sonst kennt Leaflet die Container-Größe nicht
// CSS lokal (kein CDN)
await new Promise(resolve => {
if (document.querySelector('link[href*="leaflet"]')) { resolve(); return; }
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';
link.onload = resolve;
link.onerror = resolve; // weiter auch wenn CDN nicht erreichbar
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = '/css/leaflet.css';
link.onload = resolve;
link.onerror = resolve;
document.head.appendChild(link);
});
// JS laden
// JS lokal (kein CDN)
await new Promise((resolve, reject) => {
if (document.querySelector('script[src*="leaflet"]')) { resolve(); return; }
const s = document.createElement('script');
s.src = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js';
s.src = '/js/leaflet.js';
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
@ -133,13 +133,6 @@ window.Page_poison = (() => {
maxZoom: 19,
}).addTo(_map);
// Attribution komplett unterdrücken — per Style-Injection (cache-sicher)
if (!document.getElementById('leaflet-attribution-hide')) {
const s = document.createElement('style');
s.id = 'leaflet-attribution-hide';
s.textContent = '.leaflet-control-attribution { display: none !important; }';
document.head.appendChild(s);
}
}
// ----------------------------------------------------------