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

Add option to allow Select interaction logic to select overlapping features #3019

Merged
merged 1 commit into from Feb 5, 2015
Merged

Add option to allow Select interaction logic to select overlapping features #3019

merged 1 commit into from Feb 5, 2015

Conversation

bjornharrtell
Copy link
Contributor

The original default behaviour of the Select interaction is to "Replace the currently selected feature(s) with the feature at the pixel". I made this code change to change the semantics to "Replace the currently selected feature(s) with the feature(s) at the pixel". I could not find a way to configure to get the desired behaviour with add/remove/toggle conditions).

This PR is a proposal with some unanswered questions. The "no change" condition was and is at fault since it only compares the first of the current selected features. I'm prepared to rework the PR if the questions can be resolved.

What is a sensible default behaviour?

Should the default behaviour be configurable?

@tschaub
Copy link
Member

tschaub commented Dec 8, 2014

I like the idea of adding flexibility here, but I don't think we should change the default behavior. It makes sense to me that the default behavior is to work with one feature at a time. It would be nice to have an option to be able to add/remove multiple features per gesture.

@ghost
Copy link

ghost commented Dec 8, 2014

Reworked as an optional feature.

I'm still at odds with the "no change" condition. It should work as before in the default case but when enabling multi I'm guessing it can't be the right logic. I'll try to get my head around it eventually.

@bjornharrtell bjornharrtell changed the title Change default Select interaction logic to select overlapping features Add option to allow Select interaction logic to select overlapping features Dec 8, 2014
@tschaub tschaub modified the milestone: v3.2.0 Dec 22, 2014
@elemoine
Copy link
Member

elemoine commented Feb 2, 2015

Anyone wants to review this for 3.2? I'll move it to v3.3.0 if not reviewed by tomorrow Wednesday.

* @private
* @type {boolean}
*/
this.multi_ = goog.isDef(options.multi) ?
Copy link
Member

Choose a reason for hiding this comment

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

should be in a single line

@bjornharrtell
Copy link
Contributor Author

Thanks for the review @fredj, I've fixed those and squashed to a single commit. Travis CI build fails and I can get the same error locally but I don't understand what it means or how it can be related to my branch.

@@ -2337,7 +2337,8 @@ olx.interaction.PinchZoomOptions.prototype.duration;
* layers: (Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined),
* removeCondition: (ol.events.ConditionType|undefined),
* toggleCondition: (ol.events.ConditionType|undefined)}}
* toggleCondition: (ol.events.ConditionType|undefined),
* multi: {boolean|undefined}}
Copy link
Member

Choose a reason for hiding this comment

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

Use parenthesis, not curly braces

@bjornharrtell
Copy link
Contributor Author

Thanks @gberaudo, don't know why I missed that. Fixed with updated squashed commit.

@@ -2519,7 +2519,8 @@ olx.interaction.PointerOptions.prototype.handleUpEvent;
* layers: (Array.<ol.layer.Layer>|function(ol.layer.Layer): boolean|undefined),
* style: (ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined),
* removeCondition: (ol.events.ConditionType|undefined),
* toggleCondition: (ol.events.ConditionType|undefined)}}
* toggleCondition: (ol.events.ConditionType|undefined),
* multi: (boolean|undefined)}
Copy link
Member

Choose a reason for hiding this comment

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

a final } is missing

@bjornharrtell
Copy link
Contributor Author

Thanks @fredj, fixed missing curly brace, and that seem to have made Travis happy. Will try to avoid similar typos in the future.

@fredj
Copy link
Member

fredj commented Feb 5, 2015

LVGTM, thanks @bjornharrtell

fredj added a commit that referenced this pull request Feb 5, 2015
Add option to allow Select interaction logic to select overlapping features
@fredj fredj merged commit 0906bf0 into openlayers:master Feb 5, 2015
@tschaub
Copy link
Member

tschaub commented Feb 9, 2015

It looks like this introduced a regression in behavior. See #3218 (and a mailing list issue which may or may not be related).

@bjornharrtell
Copy link
Contributor Author

The intention was to keep the existing behaviour and I when looking at the changes I don't understand what is causing the regression. The feature that gets selected should be the last one returned by forEachFeatureAtPixel both before and after this change.

@fredj
Copy link
Member

fredj commented Feb 10, 2015

In the previous implementation, the first feature was returned by map.forEachFeatureAtPixel not the last (i just figured it out now).
The reason is that if something "truthy" is returned by the function the loop stops.

See #3221 for a fix

@bjornharrtell bjornharrtell deleted the selectmulti branch March 4, 2015 07:52
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.

None yet

5 participants