MCPcopy Create free account
hub / github.com/developmentseed/stac-react / addDrawControl

Function addDrawControl

example/src/pages/Main/Map.jsx:14–36  ·  view source on GitHub ↗
(map, drawingCompleted)

Source from the content-addressed store, hash-verified

12mapbox.accessToken = process.env.REACT_APP_MAPBOX_TOKEN || '';
13
14const addDrawControl = (map, drawingCompleted) => {
15 const { modes } = MapboxDraw;
16
17 const options = {
18 modes: {
19 ...modes,
20 draw_rectangle: DrawRectangle,
21 static: StaticMode,
22 },
23 boxSelect: false,
24 displayControlsDefault: false,
25 };
26 const draw = new MapboxDraw(options);
27 map.addControl(draw);
28 map.on('draw.create', (e) => {
29 const { features } = e;
30 const feature = features[0];
31 map.getCanvas().style.cursor = '';
32 setTimeout(() => draw.changeMode('static'), 0);
33 drawingCompleted(feature);
34 });
35 return draw;
36};
37
38function Map({ className, isBboxDrawEnabled, handleDrawComplete, items }) {
39 const mapContainerRef = useRef();

Callers 1

MapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected