diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-21 17:31:38 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-21 17:31:38 -0700 |
commit | 90b87123fe6597e080d2ab03463f50617cd2c5dd (patch) | |
tree | fb0df23db12e904ed60f476b3c67f22858a7cdec /modern/src/map/PositionsMap.js | |
parent | afed83a89ecea62f7f1fd3ae3c99cdf95e52dab6 (diff) | |
download | trackermap-web-90b87123fe6597e080d2ab03463f50617cd2c5dd.tar.gz trackermap-web-90b87123fe6597e080d2ab03463f50617cd2c5dd.tar.bz2 trackermap-web-90b87123fe6597e080d2ab03463f50617cd2c5dd.zip |
Fix map switches
Diffstat (limited to 'modern/src/map/PositionsMap.js')
-rw-r--r-- | modern/src/map/PositionsMap.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modern/src/map/PositionsMap.js b/modern/src/map/PositionsMap.js index 9719b45b..8d100534 100644 --- a/modern/src/map/PositionsMap.js +++ b/modern/src/map/PositionsMap.js @@ -148,9 +148,15 @@ const PositionsMap = ({ positions }) => { map.off('click', id, onMarkerClick); map.off('click', clusters, onClusterClick); - map.removeLayer(id); - map.removeLayer(clusters); - map.removeSource(id); + if (map.getLayer(id)) { + map.removeLayer(id); + } + if (map.getLayer(clusters)) { + map.removeLayer(clusters); + } + if (map.getSource(id)) { + map.removeSource(id); + } }; }, [onMarkerClick]); |