Option to disable multi-select (shift+click) in draw.selectionchange
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?
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'.
I want just the reverse. Instead of shift + click, I want to be able to select multiple by just clicking. Is it possible?
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.
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,
},
});