From 296452214e8ffb0fb98e8933a977be82e5555869 Mon Sep 17 00:00:00 2001 From: Luiz Costa Date: Fri, 7 Jun 2024 16:40:32 +0100 Subject: [PATCH] merge --- .../fleet_management/doctype/trip/trip_list.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fleet_management/fleet_management/doctype/trip/trip_list.js b/fleet_management/fleet_management/doctype/trip/trip_list.js index 05f0343..1a6eca7 100644 --- a/fleet_management/fleet_management/doctype/trip/trip_list.js +++ b/fleet_management/fleet_management/doctype/trip/trip_list.js @@ -34,13 +34,22 @@ function create_dialog_and_init_map(frm) { }; dialog.show(); - setTimeout(() => init_map(frm), 500); // Add a delay to ensure the map loads correctly + + // Ensure the map container expands to fit its parent after the dialog is shown + setTimeout(() => { + const mapElement = document.getElementById('map'); + if (mapElement) { + mapElement.style.width = "100%"; + mapElement.style.height = "100%"; + init_map(frm); // Initialize the map + } + }, 500); // Add a delay to ensure the map loads correctly } var currentMap = null; function init_map(frm) { - console.table(window.L); + //console.table(window.L); console.log("Initializing map with MyLeaflet..."); if (currentMap !== null) { currentMap.remove(); // Remove the previous map if it exists @@ -87,7 +96,7 @@ function init_map(frm) { }, callback: function (r) { if (r.message) { - console.table(r.message); + //console.table(r.message); const data = r.message; const routeCoordinates = data.map(entry => [entry.latitude, entry.longitude]); const polyline = window.L.polyline(routeCoordinates, { color: 'red' }).addTo(map);