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:
parent
96119e02ef
commit
fbaf7c5409
7 changed files with 35 additions and 22 deletions
|
|
@ -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);
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue