diff options
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; } |