Karte: CSS-Load abwarten + invalidateSize (schwarze Karte fix)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
85bab155cb
commit
67eb515c35
1 changed files with 12 additions and 5 deletions
|
|
@ -84,6 +84,8 @@ window.Page_poison = (() => {
|
|||
|
||||
await _loadLeaflet();
|
||||
_initMap();
|
||||
// Leaflet muss nach CSS-Load die Container-Größe neu berechnen
|
||||
setTimeout(() => _map?.invalidateSize(), 100);
|
||||
await _locateAndLoad();
|
||||
}
|
||||
|
||||
|
|
@ -93,13 +95,18 @@ window.Page_poison = (() => {
|
|||
async function _loadLeaflet() {
|
||||
if (_leafletLoaded || window.L) { _leafletLoaded = true; return; }
|
||||
|
||||
if (!document.querySelector('link[href*="leaflet"]')) {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css';
|
||||
// CSS laden und auf onload warten — sonst kennt Leaflet die Container-Größe nicht
|
||||
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
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
});
|
||||
|
||||
// JS laden
|
||||
await new Promise((resolve, reject) => {
|
||||
if (document.querySelector('script[src*="leaflet"]')) { resolve(); return; }
|
||||
const s = document.createElement('script');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue