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 | |
parent | 88e62aadc90a5e5b2be41eaaaf9d32632307316a (diff) | |
download | etbsa-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.js | 12 |
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; } |