aboutsummaryrefslogtreecommitdiff
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
parent88e62aadc90a5e5b2be41eaaaf9d32632307316a (diff)
downloadtrackermap-web-e7c4812a119c4079110de5da7ccab37970b4fc08.tar.gz
trackermap-web-e7c4812a119c4079110de5da7ccab37970b4fc08.tar.bz2
trackermap-web-e7c4812a119c4079110de5da7ccab37970b4fc08.zip
Fix geofence refresh
-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 291cab75..fa5a1f63 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;
}