Routen-GL-Fix: Detail/Suggest-Karte fittet Route korrekt (Modal-0×0-Timing)

- Facade fitBounds: try/catch + skip wenn Container 0×0 (sonst NaN-LngLat im Modal)
- createMap: mehrfaches resize() nach Erstellung (Modal-Animation)
- _buildDetailMap/_suggestMap: Re-Fit nach 200/500ms (Route ganz sichtbar, Pfeile)
- Facade: scrollWheelZoom-Stub (map.scrollZoom)
This commit is contained in:
rene 2026-06-05 13:01:19 +02:00
parent 96119e02ef
commit fbaf7c5409
7 changed files with 35 additions and 22 deletions

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '1196'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '1197'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
window.APP_VERSION = APP_VERSION;

View file

@ -25,10 +25,13 @@
panTo: function (latlon) { map.panTo(_ll(latlon)); return this; },
fitBounds: function (b, opts) {
var bb = _toBounds(b);
if (bb) {
var pad = 40;
// Nur fitten wenn Bounds gültig UND der Container eine Größe hat (im Modal
// ist er beim Erstellen 0×0 → fitBounds würde NaN werfen; der Re-Fit nach
// Modal-Animation greift dann).
if (bb && !isNaN(bb.getWest()) && map.getContainer().clientWidth > 0) {
var pad = 30;
if (opts && opts.padding) pad = Array.isArray(opts.padding) ? opts.padding[0] : opts.padding;
map.fitBounds(bb, { padding: pad, maxZoom: opts && opts.maxZoom, duration: 0 });
try { map.fitBounds(bb, { padding: pad, maxZoom: opts && opts.maxZoom, duration: 0 }); } catch (e) {}
}
return this;
},
@ -46,6 +49,8 @@
off: function (ev, fn) { map.off(ev, fn); return this; },
getZoom: function () { return map.getZoom(); },
getCenter: function () { var c = map.getCenter(); return { lat: c.lat, lng: c.lng }; },
// Leaflet-Handler-Stub (z.B. _suggestMap.scrollWheelZoom.disable()).
scrollWheelZoom: { disable: function () { try { map.scrollZoom.disable(); } catch (e) {} }, enable: function () { try { map.scrollZoom.enable(); } catch (e) {} } },
// Distanz in Metern (Haversine) — Ersatz für Leaflets map.distance.
distance: function (a, b) {
var la = a.lat != null ? a.lat : a[0], lo = a.lng != null ? a.lng : a[1];
@ -177,6 +182,10 @@
map.addControl(new maplibregl.AttributionControl({
compact: true, customAttribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
}));
// Container kann beim Erstellen (Modal/Animation) noch 0×0 sein → mehrfach resizen.
var _rz = function () { try { map.resize(); } catch (e) {} };
requestAnimationFrame(_rz);
setTimeout(_rz, 120); setTimeout(_rz, 400);
return _wrapMap(map);
},

View file

@ -617,8 +617,8 @@ window.Page_routes = (() => {
UI.map.circleMarker(lls[0], { radius:7, color:'#22C55E', fillColor:'#22C55E', fillOpacity:1, weight:2 }).addTo(_suggestMap);
UI.map.circleMarker(lls.at(-1), { radius:7, color:'#EF4444', fillColor:'#EF4444', fillOpacity:1, weight:2 }).addTo(_suggestMap);
_addRouteArrows(_suggestMap, track, '#3b82f6');
_suggestMap.fitBounds(poly.getBounds(), { padding: [16, 16] });
setTimeout(() => _suggestMap?.invalidateSize(), 120);
const _sfit = () => { _suggestMap?.invalidateSize(); _suggestMap?.fitBounds(poly.getBounds(), { padding: [16, 16] }); };
_sfit(); setTimeout(_sfit, 200); setTimeout(_sfit, 500);
};
_initMap();
@ -2653,7 +2653,11 @@ window.Page_routes = (() => {
_addRouteArrows(m, track, '#3b82f6');
UI.map.circleMarker(lls[0], { radius:7, color:'#22C55E', fillColor:'#22C55E', fillOpacity:1 }).addTo(m);
UI.map.circleMarker(lls.at(-1), { radius:7, color:'#EF4444', fillColor:'#EF4444', fillOpacity:1 }).addTo(m);
m.fitBounds(poly.getBounds(), { padding:[10,10] });
// Mehrfach fitten: beim Erstellen ist der Modal-Container evtl. noch 0×0 → nach
// der Animation (resize) erneut auf die ganze Route zoomen.
const _fit = () => { m.invalidateSize(); m.fitBounds(poly.getBounds(), { padding:[16,16] }); };
_fit();
setTimeout(_fit, 200); setTimeout(_fit, 500);
return m;
}