mapbox / mapbox-gl-draw

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

Add box-selection mode for selecting multiple vertices at once #946

Open csimpi opened 4 years ago

csimpi commented 4 years ago

mapbox-gl-js version: newest mapbox-gl-draw version: newest

Steps to Trigger Behavior

-

Expected Behavior

I would like to select verticles programatically. Currently I can't see the possibility of selecting only a couple of verticles of a polygon.

I'd like to add a function when I hold a key + click + drag draw a bounding box which selects the verticles of the selected feature within the bounding box.

Draw a bbox and select features example: https://docs.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/

I want the same but selecting the vertex of the currently selected feature instead the whole feature's each vertex.

Actual Behavior

Currently, If I want to select multiple vertexes I have to zoom in, hold the shift key and click vertexes one-by-one which is very slow and frustrating, especially when I'm working with a bigger geojson file (5MB).

Why I need it? Sometimes there are many unneccessary points within a polygon that I want to remove.

kkaefer commented 4 years ago

Thanks for your feature request. The title mentions selecting them programmatically, however, the description is about a rectangle/box selection mode. Which feature are you requesting?

csimpi commented 4 years ago

@kkaefer

I'd like to select multiple vertexes with a rectangle/selection box. If there's a way to select multiple vertexes of a polygon programmatically, I can code the rectangle/selection box part, but I can't see in the docs if this is even possible. I can see that I can programmatically select a whole polygon but can't find a function to select vertexes. Like selectVertexes(coordinates:any[]).

I've studied the custom-mode part and it might be possible, but I'm not sure.

If you'd ship a complete solution in da house, that'd be awesome too :)

yuting816 commented 3 years ago

having the same problem here...

karl-axel-linstrom commented 2 years ago

i would certainly appreachiate programmatic vertex selection so hopefully any implementation of this would also add to the programatic selection options