mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

How to pass `state` of mode to a custom mode method from outside of mode? (i.e. button on map)

Open varna opened this issue 2 years ago • 1 comments

Hello,

I'm forking draw_polygon and direct_select modes into a single custom draw mode. While adding undo/redo feature I came into a problem. I can't access the state of draw mode from outside.

All native methods like onStop, onClick, onDrag etc. receive state, e as arguments. But if I add custom methods, I have to pass the state from native methods to them. It worked well for now, but when I added undo button to the map, I can't access pass the state from it cause I don't have it.

I probably need to create actionable. I can see them here, but I'm not sure how to add one of my own.

Or maybe I should scrap the idea of using state created by draw mode and implement it with my own state manager?

varna avatar Oct 31 '22 17:10 varna

Did you find a way to achieve this ?

toniopelo avatar Dec 30 '23 16:12 toniopelo