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

Option to be able to drag the feature in direct_select mode #452

Closed
wants to merge 6 commits into from

Conversation

kirach
Copy link
Contributor

@kirach kirach commented Jul 5, 2016

Hi!

We use this library a lot for our project: https://compstak.com

And recently we released a new version with Google maps replaced by Mapbox GL maps. Everything works like a charm, thanks for your work. But there is one issue and we have a couple users that already complained about it - so it's pretty important for us.

Little story: we use maps for search. And users are able to use different map search tools. One of these tools is so called "polygon search": user just puts a polygon shape to the map and should be able to resize/drag it to perform search. Like this:

like this

But the problem is that your library has separate modes for dragging features (simple_select) and for resizing (direct_select). So it's not possible for us to allow users to drag and to resize polygon at the same time. (And it used to work when we had goole maps - so that's why users complain about it).

Here is my attempt to solve this issue by creating new mode. I called if mixed mode (but you can suggest better name). Basically it's just a mix of simple_select and direct_select modes.

The work is still in progress, and I have to write some tests at least. But just let me know what do you think about idea of this mode. And what else I should implement here.

Thanks!

@mcwhittemore
Copy link
Contributor

@kirach This is great. Thanks. Also, nice use of custom styles. 😄

It looks like the main goal here is to add dragging a feature to direct_select mode. Is that correct?

mixed is a bit confusing of a name. Maybe single_feature_select?

I think the next step here is to refactor the shared functionality with direct_select and simple_select out into shared files.

@kirach kirach changed the title [WIP] New mixed mode for dragging and resizing features Option to be able to drag the feature in direct_select mode Jul 11, 2016
@kirach
Copy link
Contributor Author

kirach commented Jul 11, 2016

@mcwhittemore I've just finished work on this feature. Review please.

I decided that it doesn't worth to create a separate mode for dragging feature because it's basically the direct_mode with little changes. So instead of separate mode I just added the option dragFeature to direct select mode. Also added some tests for the cases when dragFeature is enabled and disabled for direct_select mode.

Let me know what you think. If it's ok I'll update the README to add the option description.

@mcwhittemore
Copy link
Contributor

@kirach I'll give this a good look over tomorrow

ctx.map.dragPan.disable();
this.render(e.featureTarget.properties.id);

// Set up the state for drag moving
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should call startDragging() here.

@mcwhittemore
Copy link
Contributor

@kirach I liked this a bit more when it was its own mode and not a flag in a mode.

@davidtheclark and I have been talking about dropping the options argument in changeMode to help remove state for the modes so this PR is stepping into that convo a bit. #397 (comment)

It is also stepping into a convo we've been having about changing how mode handlers work.
#459

I'm pretty comfortable with adding extra modes as I want to create a way for users to create custom modes and having non-default modes as part of the tool before that happens mean we would have a few custom modes automatically when we roll out that feature.

That said... this is really close to direct_select and I'd be lying if I said I'm not tempted to make this the default behavior.

@kirach
Copy link
Contributor Author

kirach commented Jul 12, 2016

@mcwhittemore The main issue with separate mode was that it was almost 90% of copy-paste from direct_select mode. And it's hard to refactor and extract common functionality a lot of functions depend on mode state (variables which are declared in the in mode function) and context dependent (for example mode_handler calls the start method of mode passing another context for this). So I decided it's better to implement it using option for direct_select mode.

If you want - I can move back to separate mode, but it still will be a lot of copy-paste from direct_select mode. Or I can change the PR to make dragging the feature default for direct_mode. Let me know. And thanks for review!

@ilyamilosevic
Copy link
Contributor

ilyamilosevic commented Sep 1, 2016

Interesting! Recently, I had almost the same task. To avoid problem with modes I implemented a plugin similar to Leaflet AreaSelect but with ability to change hole.
map_filter

@davecranwell
Copy link

+1 for seeing this PR completed. I too use Draw to aid geo-bounded searches, and the draggability issue in the GL version, compared to the old (e.g on geojson.io) is definitely something which would greatly improve usability.

@mcwhittemore
Copy link
Contributor

This has been implemented as the default behaviour via #536. It will be out in the 0.15.0 release.

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

Successfully merging this pull request may close these issues.

4 participants