-
Notifications
You must be signed in to change notification settings - Fork 26
This is how to add control icon #10
Copy link
Copy link
Open
Description
Here is how to activate the rectangle and add it as control to the map
const modes = MapboxDraw.modes
modes.draw_rectangle = DrawRectangle
const draw = new MapboxDraw({
displayControlsDefault: false,
controls: {
polygon: true,
trash: true,
defaultMode: 'draw_rectangle',
},
modes: modes,
})
map.addControl(draw)
draw.changeMode('draw_rectangle')
map._draw = draw
map.on('draw.create', function (feature) {
console.log(feature)
})
Here you can assign draw to a property for map
map._draw = draw
const onClickDrawRt = (map) => {
map._draw.changeMode('draw_rectangle')
}
<button onClick={() => onClickDrawRt(map)}/>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels