aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-06-29 21:31:44 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-06-29 21:31:44 -0700
commite7c4812a119c4079110de5da7ccab37970b4fc08 (patch)
tree688fe03650232979068df4cacf837687557d734a /modern/src/map
parent88e62aadc90a5e5b2be41eaaaf9d32632307316a (diff)
downloadetbsa-traccar-web-e7c4812a119c4079110de5da7ccab37970b4fc08.tar.gz
etbsa-traccar-web-e7c4812a119c4079110de5da7ccab37970b4fc08.tar.bz2
etbsa-traccar-web-e7c4812a119c4079110de5da7ccab37970b4fc08.zip
Fix geofence refresh
Diffstat (limited to 'modern/src/map')
-rw-r--r--modern/src/map/GeofenceEditMap.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/modern/src/map/GeofenceEditMap.js b/modern/src/map/GeofenceEditMap.js
index 291cab7..fa5a1f6 100644
--- a/modern/src/map/GeofenceEditMap.js
+++ b/modern/src/map/GeofenceEditMap.js
@@ -34,10 +34,7 @@ const GeofenceEditMap = () => {
map.addControl(draw, 'top-left');
- draw.deleteAll();
- for (const geofence of geofences) {
- draw.add(geofenceToFeature(geofence));
- }
+
map.on('draw.create', async event => {
const feature = event.features[0];
@@ -81,6 +78,13 @@ const GeofenceEditMap = () => {
return () => map.removeControl(draw);
}, []);
+ useEffect(() => {
+ draw.deleteAll();
+ for (const geofence of geofences) {
+ draw.add(geofenceToFeature(geofence));
+ }
+ }, [geofences]);
+
return null;
}