Search code examples
mapbox-gl-jsmapbox-gl-draw

Manually fire the Mapbox-GL-Draw drawing mode


I'd like to use Mapbox-GL-Draw in an app, but want to trigger polygon drawing from a button that exists outside the Mapbox map container, and not display the normal drawing control.

A hacky way to do this would be to simply move the button after it's created, but is there a simple, cleanish way to start the drawing process?


Solution

  • Oh, it looks like the answer is as simple as:

    drawControl.changeMode('draw_polygon');