aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/MapGeofence.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-18 16:09:31 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-18 16:09:31 -0700
commitfb8f8764aae3e509df75f5d3f25daf11a19a0029 (patch)
tree36a15e08b5b48acf53089284dc6e8d3419bf46b4 /modern/src/map/MapGeofence.js
parentaa72fc6dbe2be7e3322a8a6110a6997435a0679a (diff)
downloadtrackermap-web-fb8f8764aae3e509df75f5d3f25daf11a19a0029.tar.gz
trackermap-web-fb8f8764aae3e509df75f5d3f25daf11a19a0029.tar.bz2
trackermap-web-fb8f8764aae3e509df75f5d3f25daf11a19a0029.zip
Fix geofence crash
Diffstat (limited to 'modern/src/map/MapGeofence.js')
-rw-r--r--modern/src/map/MapGeofence.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/modern/src/map/MapGeofence.js b/modern/src/map/MapGeofence.js
index 31554f11..3bfbca24 100644
--- a/modern/src/map/MapGeofence.js
+++ b/modern/src/map/MapGeofence.js
@@ -80,11 +80,13 @@ const MapGeofence = () => {
}, [mapGeofences]);
useEffect(() => {
- map.getSource(id).setData({
- type: 'FeatureCollection',
- features: Object.values(geofences).map((geofence) => geofenceToFeature(theme, geofence)),
- });
- }, [geofences]);
+ if (mapGeofences) {
+ map.getSource(id).setData({
+ type: 'FeatureCollection',
+ features: Object.values(geofences).map((geofence) => geofenceToFeature(theme, geofence)),
+ });
+ }
+ }, [mapGeofences, geofences]);
return null;
};