mapbox / mapbox-gl-draw

Draw tools for mapbox-gl-js
https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/
ISC License
942 stars 590 forks source link

Overwriting button click to draw a different object #904

Open ev0065 opened 5 years ago

ev0065 commented 5 years ago

Hi, so on my current setup I am using react-mapbox-gl with mapbox-gl-draw and mapbox-gl-draw-circle.

I am able to reroute the draw_marker or draw_line_string modes to draw circles when they are clicked, but the draw_polygon button remains routed to draw_circle, no matter where I try to overwrite it. I believe this is due to draw_circle using draw_polygon to draw the circle on the map.

For example, when I click the marker button, I made it draw a circle on the map. However, when I click the polygon button, it still draws a circle on the map instead of a regular polygon.

So, here's my question: Is it possible to overwrite a buttons for different drawing functionality? (EX: The marker button draws a circle and the polygon button draws a polygon, or the polygon button draws a circle and the line button draws a polygon, etc...)

Thanks!

kkaefer commented 4 years ago

It sounds like you're trying to hijack an existing button in order to toggle a custom mode. Can you use a new/custom button instead of reusing an existing one?

Aliber009 commented 3 years ago

hello ev, please can you tell me how can I reroute a button to circle mode