From 5b1d69ef52e9200c35bf8986c265a42be7cf23cf Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 13 Sep 2020 18:02:30 -0700 Subject: Clear popups on switch --- modern/src/mapManager.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modern/src') diff --git a/modern/src/mapManager.js b/modern/src/mapManager.js index 7c7e2929..c597eb58 100644 --- a/modern/src/mapManager.js +++ b/modern/src/mapManager.js @@ -86,6 +86,11 @@ const addLayer = (id, source, icon, text, onClick) => { } const removeLayer = (id, source) => { + const popups = element.getElementsByClassName('mapboxgl-popup'); + if (popups.length) { + popups[0].remove(); + } + map.off('click', id, layerClickCallbacks[id]); delete layerClickCallbacks[id]; -- cgit v1.2.3