From dae09548917207acb5c3472ea41c33bbbb2a93c5 Mon Sep 17 00:00:00 2001 From: Pringgosutono Date: Sun, 14 Sep 2025 23:09:42 +0700 Subject: [PATCH] fitBounds --- resources/views/menu_v1/reports/_trip_detail.blade.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/views/menu_v1/reports/_trip_detail.blade.php b/resources/views/menu_v1/reports/_trip_detail.blade.php index 0937da2..d2cb66d 100644 --- a/resources/views/menu_v1/reports/_trip_detail.blade.php +++ b/resources/views/menu_v1/reports/_trip_detail.blade.php @@ -108,10 +108,11 @@ $(this).text(moment.unix(unix).format('DD MMM YYYY HH:mm:ss')); }); - + let coords setTimeout(() => { map.invalidateSize(); // force Leaflet to recalc // map.fitBounds(polyline.getBounds()); + map.fitBounds(coords.map(c => L.latLng(c[0], c[1]))); }, 200); const linesData = (@json($list)); @@ -231,7 +232,7 @@ fetchOsrm(points).then(osrm => { if (!osrm) return console.log("OSRM gagal"); - const coords = osrm.routes[0].legs.flatMap(leg => + coords = osrm.routes[0].legs.flatMap(leg => leg.steps.flatMap(step => decodeOSRMGeometry(step.geometry) ) @@ -242,7 +243,7 @@ weight: 3, opacity: 0.8 }).addTo(map); - map.fitBounds(coords.map(c => L.latLng(c[0], c[1]))); + // map.fitBounds(coords.map(c => L.latLng(c[0], c[1]))); });