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

Option to disable multi-select (shift+click) in draw.selectionchange

Open awulkan opened this issue 5 years ago • 5 comments

Hey, I would like to be able to disable multi-select of features by using shift+click. This is a functionality of draw.selectionchange. I have already disabled boxSelect and keybindings, but it didn't help.

Is there any current workaround for this, in order to prevent multi-select?

awulkan avatar May 13 '20 08:05 awulkan

Yes, please. Any pointers in this direction - I will be infinitely grateful.

I'm currently trying to implement a system where if selecting multiple features, the UI automatically removes the previous selection and goes with the most recent, (effectively eliminating multi-select) however I am failing miserably. I am very deep down a 'custom mode rabbit hole'.

garretteklof avatar Oct 14 '20 08:10 garretteklof

I want just the reverse. Instead of shift + click, I want to be able to select multiple by just clicking. Is it possible?

intermx-vignesh avatar Nov 18 '21 12:11 intermx-vignesh

I am not sure if this helps But I faced same issue I modified the function that fires when draw.selectionchange I manually trigger the draw to changeMode to simple_select or direct_select and pass the first id only from features args

const onSelectionChange = ({ features }: DrawSelectionChangeEvent) => { if (features.length > 0) { controller.changeMode(DrawMode.DIRECT_SELECT, { featureId: features[0].id as string }) }}

I am using react-map-gl as a wrapper to mapbox And returning MapboxDraw instance feom useControl hook I use this instance to trigger mode change manually.

arsanyjoseph avatar Oct 11 '23 21:10 arsanyjoseph

There is a boxSelect option you can set to false to disable this

const draw = new MapboxDraw({
  displayControlsDefault: false,
  userProperties: true,
  boxSelect: false,
  controls: {
    point: true,
    line_string: true,
    polygon: true,
    trash: true,
    combine_features: true,
    uncombine_features: true,
  },
});

ArmandBahi avatar May 02 '24 07:05 ArmandBahi