diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-29 21:31:44 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-29 21:31:44 -0700 |
commit | e7c4812a119c4079110de5da7ccab37970b4fc08 (patch) | |
tree | 688fe03650232979068df4cacf837687557d734a /modern/src/map/GeofenceEditMap.js | |
parent | 88e62aadc90a5e5b2be41eaaaf9d32632307316a (diff) | |
download | trackermap-web-e7c4812a119c4079110de5da7ccab37970b4fc08.tar.gz trackermap-web-e7c4812a119c4079110de5da7ccab37970b4fc08.tar.bz2 trackermap-web-e7c4812a119c4079110de5da7ccab37970b4fc08.zip |
Fix geofence refresh
Diffstat (limited to 'modern/src/map/GeofenceEditMap.js')
-rw-r--r-- | modern/src/map/GeofenceEditMap.js | 12 |
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; } |