diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js index fa702e3..5789808 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js @@ -4485,7 +4485,16 @@ function _initMapWhenReady() { if (loadingEl) loadingEl.classList.add("is-hidden"); window.trx.map.initAprsMap(); window.trx.map.sizeAprsMapToViewport(); - if (window.trx.map.aprsMap) setTimeout(() => window.trx.map.aprsMap.invalidateSize(), 50); + // The map panel was just made visible (display:none → ""); the browser + // may not have laid it out yet, so getBoundingClientRect() can return + // stale/zero dimensions. Double-rAF ensures a full layout pass has + // completed before we re-measure and tell Leaflet about its real size. + requestAnimationFrame(() => { + requestAnimationFrame(() => { + window.trx.map.sizeAprsMapToViewport(); + if (window.trx.map.aprsMap) window.trx.map.aprsMap.invalidateSize(); + }); + }); return; } // Not ready yet — show overlay and poll until both are available. diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/map-core.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/map-core.js index 3c18bad..84baff4 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/map-core.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/map-core.js @@ -1848,10 +1848,13 @@ initAprsMap(); sizeAprsMapToViewport(); if (aprsMap) { - setTimeout(() => { - aprsMap.invalidateSize(); - aprsMap.setView([lat, lon], 13); - }, 50); + requestAnimationFrame(() => { + requestAnimationFrame(() => { + sizeAprsMapToViewport(); + aprsMap.invalidateSize(); + aprsMap.setView([lat, lon], 13); + }); + }); } }; @@ -1896,6 +1899,7 @@ const center = locatorMarkerCenter(marker); const focusMarker = () => { if (!aprsMap || !marker) return; + sizeAprsMapToViewport(); aprsMap.invalidateSize(); if (center) { const targetZoom = Math.max(aprsMap.getZoom() || 0, 7); @@ -1910,7 +1914,9 @@ if (typeof marker.openPopup === "function") marker.openPopup(); }; focusMarker(); - setTimeout(focusMarker, 60); + requestAnimationFrame(() => { + requestAnimationFrame(focusMarker); + }); return true; };