From fdad6f72c32907d3a420d7ada823436e076ba78f Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 15 May 2024 09:01:11 +0200 Subject: [PATCH] fix(apis_entities): fix faulty map JS Fix references to longitude, latitude values, incorrect check for existing map. --- .../apis_core/apis_entities/abstractentity_form.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html b/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html index 27e3be8bf..f2b18f181 100644 --- a/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html +++ b/apis_core/apis_entities/templates/apis_core/apis_entities/abstractentity_form.html @@ -175,6 +175,7 @@ function showMap(element) { $('.popover').remove(); + let map; let rect = element.getBoundingClientRect(); let pTop = rect.top + window.scrollY - 250; @@ -187,13 +188,13 @@ $(mapDiv).offset({top: pTop, left: pLeft}); document.body.appendChild(mapDiv); - if (typeof map != "undefined") { map.off(); map.remove(); } + if (typeof map !== "undefined") { map.off(); map.remove(); } - let map = L.map('popovermap', { center: [element.dataset.lat, element.dataset.lng], zoom: 5 }); + map = L.map('popovermap', { center: [parseInt(element.dataset.latitude), parseInt(element.dataset.longitude)], zoom: 5 }); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); - L.marker([element.dataset.lat, element.dataset.lng]).addTo(map); + L.marker([parseInt(element.dataset.latitude), parseInt(element.dataset.longitude)]).addTo(map); } function delMap(element) {