From 8dc48316f31308db39ee68b4573912d5afcb4926 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 31 Mar 2024 12:45:32 +1300 Subject: [PATCH] shouldn't attach click listener more than once... --- src/public/index.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/public/index.html b/src/public/index.html index 4dffd8c..326541c 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -1701,6 +1701,20 @@ }); + // close all tooltips and popups when clicking map + map.on("click", function(event) { + + // do nothing when clicking inside tooltip + const clickedElement = event.originalEvent.target; + if(elementOrAnyAncestorHasClass(clickedElement, "leaflet-tooltip")){ + return; + } + + closeAllTooltips(); + closeAllPopups(); + + }); + function isValidLatLng(lat, lng) { if(isNaN(lat) || isNaN(lng)){ @@ -1955,20 +1969,6 @@ }); - // close all tooltips and popups when clicking map - map.on("click", function(event) { - - // do nothing when clicking inside tooltip - const clickedElement = event.originalEvent.target; - if(elementOrAnyAncestorHasClass(clickedElement, "leaflet-tooltip")){ - return; - } - - closeAllTooltips(); - closeAllPopups(); - - }); - // add to cache nodes.push(node); nodeMarkers[node.node_id] = marker;