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

Trash is disabled while programatically selecting feature from draw using direct select

Open jithintomz opened this issue 7 years ago • 5 comments

I am trying to select a newly created object in draw in code.

created_ids = draw.add(draw_feature); draw.changeMode('direct_select',{featureId:created_ids[0]});

The feature gets selected,but delete does not work on clicking trash icon. When I deselect and reselect the feature using pointer delete works.

jithintomz avatar Dec 05 '17 09:12 jithintomz

@jithintomz please provide a fiddle of this bug happening along with the versions of mapbox-gl-draw and mapbox-gl-js that you are using per the issue template.

Regards, Matthew

mcwhittemore avatar Dec 05 '17 15:12 mcwhittemore

This happens even on the example at https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/

  1. Draw a polygon.
  2. Select it.
  3. Press delete.

It wont work.

However, if you deselect it, then re-select it, you can delete.

n15e avatar Jan 17 '19 18:01 n15e

Any update on this issue?

ka7eh avatar Feb 13 '19 23:02 ka7eh

Here is the solution for deleting polygon. created_ids = draw.add(draw_feature); draw.changeMode('simple_select',{featureIds:[created_ids[0]]}); It's working at my side, I hope it will work for you too.

suraj-bharti avatar Nov 27 '20 10:11 suraj-bharti

FYI, it seems that not deleting a feature from direct select mode is intended behavior. However, you can override the mode's toTrash function and get it working. See this PR for how:

https://github.com/mapbox/mapbox-gl-draw/pull/975

neodescis avatar Jan 16 '23 19:01 neodescis