aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/GeofenceMap.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-08-21 17:31:38 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-08-21 17:31:38 -0700
commit90b87123fe6597e080d2ab03463f50617cd2c5dd (patch)
treefb0df23db12e904ed60f476b3c67f22858a7cdec /modern/src/map/GeofenceMap.js
parentafed83a89ecea62f7f1fd3ae3c99cdf95e52dab6 (diff)
downloadetbsa-traccar-web-90b87123fe6597e080d2ab03463f50617cd2c5dd.tar.gz
etbsa-traccar-web-90b87123fe6597e080d2ab03463f50617cd2c5dd.tar.bz2
etbsa-traccar-web-90b87123fe6597e080d2ab03463f50617cd2c5dd.zip
Fix map switches
Diffstat (limited to 'modern/src/map/GeofenceMap.js')
-rw-r--r--modern/src/map/GeofenceMap.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/modern/src/map/GeofenceMap.js b/modern/src/map/GeofenceMap.js
index d00cbb1..c0ecef4 100644
--- a/modern/src/map/GeofenceMap.js
+++ b/modern/src/map/GeofenceMap.js
@@ -56,10 +56,18 @@ const GeofenceMap = () => {
});
return () => {
- map.removeLayer('geofences-fill');
- map.removeLayer('geofences-line');
- map.removeLayer('geofences-title');
- map.removeSource(id);
+ if (map.getLayer('geofences-fill')) {
+ map.removeLayer('geofences-fill');
+ }
+ if (map.getLayer('geofences-line')) {
+ map.removeLayer('geofences-line');
+ }
+ if (map.getLayer('geofences-title')) {
+ map.removeLayer('geofences-title');
+ }
+ if (map.getSource(id)) {
+ map.removeSource(id);
+ }
};
}, []);