From 8d32ac6e16c2b9ceb2a23edf0d6254d1e318c31b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 24 Oct 2020 22:24:23 -0700 Subject: Add geofence editing --- modern/src/map/GeofenceMap.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 modern/src/map/GeofenceMap.js (limited to 'modern/src/map/GeofenceMap.js') diff --git a/modern/src/map/GeofenceMap.js b/modern/src/map/GeofenceMap.js new file mode 100644 index 0000000..bca4d20 --- /dev/null +++ b/modern/src/map/GeofenceMap.js @@ -0,0 +1,25 @@ +import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css' +import MapboxDraw from '@mapbox/mapbox-gl-draw'; +import { useEffect } from 'react'; + +import { map } from './Map'; + +const draw = new MapboxDraw({ + displayControlsDefault: false, + controls: { + polygon: true, + trash: true, + }, +}); + +const GeofenceMap = () => { + useEffect(() => { + const mm = map; + map.addControl(draw, 'top-left'); + return () => map.removeControl(draw); + }, []); + + return null; +} + +export default GeofenceMap; -- cgit v1.2.3