Closed timeroute closed 4 years ago
/cc @boyur
Install one of the custom modes: https://github.com/mapbox/mapbox-gl-draw/blob/master/docs/MODES.md#available-custom-modes
for instance the rectangle mode:
https://github.com/thegisdev/mapbox-gl-draw-rectangle-mode
yarn add mapbox-gl-draw-rectangle-mode
import DrawRectangle and add it to defaultModes:
import Draw from '@urbica/react-map-gl-draw'
import DrawRectangle from 'mapbox-gl-draw-rectangle-mode'
⋮
const [editMode, setEditMode] = useState('simple_select')
⋮
<Draw
mode={editMode}
modes={defaultModes => ({
...defaultModes,
draw_rectangle: DrawRectangle
})}
/>
change the editMode to rectangle:
setEditMode('draw_rectangle')
@KaiHuebner Thanks!
I want to create a custom mode with mapboxgl-draw, how can I do???