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

Deselect ovelapping features is broken #2936

Merged
merged 2 commits into from
Nov 13, 2014

Conversation

ahocevar
Copy link
Member

With Select in a toggle mode, clicking a point where there’s overlapping selected features, results in “Uncaught TypeError: Cannot read property 'closure_uid_xxxxxxx’ of undefined” from goog.getUid.

There appears to be a bug in Select.handleMapBrowserEvent: Deselected array containing matching feature indexes is iterated in reverse order and features are removed by this index. It assumes that deselected indexes are in ascending order as to remove them starting from the end of features collection, but as it happens, the indexes are actually in descending order and it starts to remove them from the start of the collection and runs into undefined halfway through when all features overlap.

@ahocevar
Copy link
Member

Pull request attached.

@@ -154,7 +154,7 @@ ol.interaction.Select.prototype.handleMapBrowserEvent =
}
} else {
// Modify the currently selected feature(s).
var /** @type {Array.<number>} */ deselected = [];
var /** @type {Array.<ol.Feature>} */ deselected = [];
Copy link
Member

Choose a reason for hiding this comment

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

You'll need to also push the feature onto the deselected array (the index is still pushed), right?

Bummer that neither the compiler nor our tests catch this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Bummer indeed. What are type annotations for when the compiler does not check against them? And then of course the other shortcoming is that we don't have unit tests at all for the select interaction.

@ssaarela
Copy link
Author

Thanks for quick response! Any idea when this fix will end up in a release?

I'm working on an open source and open data application that handles parking facilities: https://github.com/HSLdevcom/parkandrideAPI/blob/gates/application/src/main/frontend/src/app/facilities/facilityMap.js

ahocevar added a commit that referenced this pull request Nov 13, 2014
Fix unselection of selected features
@ahocevar ahocevar merged commit cee1575 into openlayers:master Nov 13, 2014
@ahocevar ahocevar deleted the unselect-index branch November 13, 2014 07:39
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

3 participants