mirror of
https://github.com/itsdave-de/fusionpbx_connect.git
synced 2025-05-06 23:55:21 +02:00
merge branch
This commit is contained in:
commit
35b27be53d
@ -8,7 +8,7 @@ function loadLeafletAndInitMap(frm, callback) {
|
|||||||
function create_dialog_and_init_map(frm) {
|
function create_dialog_and_init_map(frm) {
|
||||||
const dialog = new frappe.ui.Dialog({
|
const dialog = new frappe.ui.Dialog({
|
||||||
title: 'Show Route',
|
title: 'Show Route',
|
||||||
fields: [{ fieldtype: 'HTML', fieldname: 'map_html', label: 'Map', options: '<div id="map" style="width:100%;height:100%;"></div>' }],
|
fields: [{ fieldtype: 'HTML', fieldname: 'map_html', label: 'Map', options: '<div id="map" style="height:calc(80vh - 20px);"></div>' }],
|
||||||
primary_action_label: 'Close',
|
primary_action_label: 'Close',
|
||||||
primary_action() {
|
primary_action() {
|
||||||
if (currentMap) {
|
if (currentMap) {
|
||||||
@ -16,15 +16,17 @@ function create_dialog_and_init_map(frm) {
|
|||||||
currentMap = null; // unset the reference
|
currentMap = null; // unset the reference
|
||||||
}
|
}
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
}
|
},
|
||||||
|
size: 'extra-large'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Adjust the size of the dialog dynamically to 80% of the browser window
|
// Adjust the size of the dialog dynamically to 80% of the browser window
|
||||||
const modalContent = dialog.$wrapper.find('.modal-content');
|
const modalDialog = dialog.$wrapper.find('.modal-content');
|
||||||
modalContent.css("width", "80vw");
|
modalDialog.css({
|
||||||
modalContent.css("height", "80vh");
|
"width": "85vw",
|
||||||
modalContent.css("max-width", "none"); // Ensure no max-width restrictions
|
"max-width": "85vw",
|
||||||
modalContent.css("margin", "auto"); // Center the modal
|
"margin-left": "-25vh"
|
||||||
|
});
|
||||||
|
|
||||||
// Add hide event to reload the page when the dialog is closed
|
// Add hide event to reload the page when the dialog is closed
|
||||||
dialog.onhide = function () {
|
dialog.onhide = function () {
|
||||||
@ -32,22 +34,13 @@ function create_dialog_and_init_map(frm) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dialog.show();
|
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;
|
var currentMap = null;
|
||||||
|
|
||||||
function init_map(frm) {
|
function init_map(frm) {
|
||||||
//console.table(window.L);
|
console.table(window.L);
|
||||||
console.log("Initializing map with MyLeaflet...");
|
console.log("Initializing map with MyLeaflet...");
|
||||||
if (currentMap !== null) {
|
if (currentMap !== null) {
|
||||||
currentMap.remove(); // Remove the previous map if it exists
|
currentMap.remove(); // Remove the previous map if it exists
|
||||||
@ -94,7 +87,7 @@ function init_map(frm) {
|
|||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
//console.table(r.message);
|
console.table(r.message);
|
||||||
const data = r.message;
|
const data = r.message;
|
||||||
const routeCoordinates = data.map(entry => [entry.latitude, entry.longitude]);
|
const routeCoordinates = data.map(entry => [entry.latitude, entry.longitude]);
|
||||||
const polyline = window.L.polyline(routeCoordinates, { color: 'red' }).addTo(map);
|
const polyline = window.L.polyline(routeCoordinates, { color: 'red' }).addTo(map);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user