Skip to content

Commit

Permalink
style(apis_entities): update map JS
Browse files Browse the repository at this point in the history
Update JS variable names, keywords following
JavaScript best practices; reorder statements
for readabilty.
  • Loading branch information
koeaw committed May 15, 2024
1 parent 3c7da82 commit 60b6266
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,30 @@
};
activate_editing();

function showmap(element) {
function showMap(element) {
$('.popover').remove();
var rect = element.getBoundingClientRect();

mapdiv = document.createElement("div");
mapdiv.classList.add("popover");
mapdiv.setAttribute("id", "popovermap");
ptop = rect.top + window.scrollY - 250;
pleft = rect.left + window.scrollX - 550;
$(mapdiv).offset({top: ptop, left: pleft});
document.body.appendChild(mapdiv);
let rect = element.getBoundingClientRect();
let pTop = rect.top + window.scrollY - 250;
let pLeft = rect.left + window.scrollX - 550;

let mapDiv = document.createElement("div");
mapDiv.classList.add("popover");
mapDiv.setAttribute("id", "popovermap");

$(mapDiv).offset({top: pTop, left: pLeft});
document.body.appendChild(mapDiv);

if (typeof map != "undefined") { map.off(); map.remove(); }
map = L.map('popovermap', { center: [element.dataset.lat, element.dataset.lng], zoom: 5 });
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo(map);

let map = L.map('popovermap', { center: [element.dataset.lat, element.dataset.lng], zoom: 5 });
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([element.dataset.lat, element.dataset.lng]).addTo(map);
};
}

function delmap(element) {
function delMap(element) {
$('.popover').remove();
}
</script>
Expand Down

0 comments on commit 60b6266

Please sign in to comment.