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

Question: is it possible to add a feature and go directly into 'live' edit mode?

Open vomc opened this issue 5 years ago • 6 comments

I can use the control just fine and pass in geoJson but I would like to not have the user need to double click to get into the 'active' draw mode. Not sure how to describe this but the mode where (using default styling), the lines are dashed and you have movable vertices.

RIght now when I load my geoJson into the draw control, I get a featureId and then I use that to do drawControl.changeMode('direct_select', { featureId: featureId }) but this shows the mode where my feature is not rendered using the orange dotted lines. I still have to double click to engage that mode...

Thank you!

vomc avatar Feb 03 '20 17:02 vomc

Interested in this too.

skol-pro avatar Feb 05 '20 07:02 skol-pro

Interested in this too.

hesitanting avatar Feb 13 '20 09:02 hesitanting

Here's another variation of the same basic problem (direct_select allows line movement):

  1. Create a line_string in code.

  2. User clicks on the line.

  3. Try to go immediately to direct_select:

    map.on('draw.selectionchange', (e) => { 
        draw.changeMode('direct_select', { featureId: features[0].id });
        console.log ("draw.selectionchange: ", draw.getMode());  // direct_select
    }
    
  4. At this point the line can be dragged by the mouse, even though this capability should be disabled.

  5. If a vertex is dragged, suddenly the problem disappears and the line itself can no longer be dragged.

So it looks like changeMode("direct_select") fails to set some internal state which is only set when a vertex is selected.

jaybo avatar May 08 '20 06:05 jaybo

From looking at the code and description, I'm guessing this would be fixed by pull request https://github.com/mapbox/mapbox-gl-draw/pull/901

jaybo avatar May 08 '20 15:05 jaybo

Interested in this too.

ZLQkeeper avatar May 21 '21 03:05 ZLQkeeper

Interested in this too.

markel-lx avatar Oct 12 '22 07:10 markel-lx