From b2ca4606ef22eb6980a079b034bfb8f16052e05b Mon Sep 17 00:00:00 2001 From: jcardus Date: Sun, 30 Jul 2023 02:22:51 +0100 Subject: remove both sources --- modern/src/map/MapPositions.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modern/src/map/MapPositions.js b/modern/src/map/MapPositions.js index 68073fab..600a6373 100644 --- a/modern/src/map/MapPositions.js +++ b/modern/src/map/MapPositions.js @@ -172,6 +172,10 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF map.off('click', clusters, onClusterClick); map.off('click', onMapClick); + if (map.getLayer(clusters)) { + map.removeLayer(clusters); + } + [id, selected].forEach((id) => { if (map.getLayer(id)) { map.removeLayer(id); @@ -179,13 +183,10 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleF if (map.getLayer(`direction-${id}`)) { map.removeLayer(`direction-${id}`); } + if (map.getSource(id)) { + map.removeSource(id); + } }); - if (map.getLayer(clusters)) { - map.removeLayer(clusters); - } - if (map.getSource(id)) { - map.removeSource(id); - } }; }, [mapCluster, clusters, onMarkerClick, onClusterClick]); -- cgit v1.2.3