Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Multi-Select #432

Open
neodescis opened this issue Jan 20, 2025 · 1 comment
Open

[Feature Request] Multi-Select #432

neodescis opened this issue Jan 20, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@neodescis
Copy link

neodescis commented Jan 20, 2025

Is your feature request related to a problem? Please describe.
We are currently using Mapbox Draw, and I am looking to migrate our project to Terra Draw. Our project allows a user to select multiple Mapbox Draw features on the map at once (multi-select), essentially to "OR" them together logically in order to create a geospatial data query. However, in going through the code for Terra Draw's select mode, it looks like the mode does not currently support multi-select. Is this something that is on the roadmap?

Describe your proposed idea for the solution to this problem
When in selection mode, if the user already has a feature selected, holds down the ctrl or shift key, and then clicks on another feature, that feature should also be selected. I would maybe expect the control points for features to go away when multiple features are selected, but I suppose either way would be fine.

Describe alternatives you've considered
A separate multi-select mode could be created instead, but this seems like it should be an option on the existing select mode. I don't think a user should need to know whether they want to go into multi-select or single-select/edit mode. Also, rather than holding down ctrl or shift, maybe clicking on each feature would toggle its selected state? Maybe either way could be supported.

@neodescis neodescis added the enhancement New feature or request label Jan 20, 2025
@neodescis
Copy link
Author

neodescis commented Jan 22, 2025

It's not pretty, but I've managed to hack something together that achieves the functionality I'm after:

https://stackblitz.com/edit/stackblitz-starters-sajprtlr?file=src%2Fapp%2Fapp.component.ts

Basically, this does the following:

  • Tracks a feature being created in a draw mode and styles it differently
  • Tracks its own notion of features being "selected," which is toggled for each feature when it is clicked (or gets a contextmenu event, i.e. is right-clicked), and styles "selected" features differently
  • Clears the "selected" state of all features when creating a new one in any mode

Again, I realize this is not good code. However, this showcases the functionality I'm after. It's also still better than what I had to do to hack things into Mapbox Draw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant