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

forEachFeatureAtPixel returns wrong layer if feature already selected #3878

Closed
probins opened this issue Jul 6, 2015 · 7 comments
Closed
Milestone

Comments

@probins
Copy link
Contributor

probins commented Jul 6, 2015

Following situation used to work, but no longer does since removal of FeatureOverlay:

  • 2 select interactions, one on mousemove, one on click, so user gets title on hover, and can click for more details. So when clicks, the feature is already selected. Click should return the selected feature, but event.selected is empty.

This seems to be because map.forEachFeatureAtPixel is returning the wrong layer: the overlay layer not the original vector layer, so it's failing the layer filter. I think the problem is around https://github.com/openlayers/ol3/blob/master/src/ol/renderer/maprenderer.js#L173 which I think should also be applying the layer filter so it only returns features on the original layers, not the overlay layer.

@bartvde bartvde added this to the v3.8.0 milestone Jul 6, 2015
@ahocevar
Copy link
Member

ahocevar commented Jul 7, 2015

Thanks for the bug report. I'm working on this now.

@ahocevar
Copy link
Member

ahocevar commented Jul 7, 2015

@probins Can you please test #3883 to see if that pull request fixes the problem?

@akrherz
Copy link

akrherz commented Jul 7, 2015

@ahocevar For what it is worth, I tested this patch and it got me past the initial bug, but now I am hitting some other issue with attempting to keep track of a clicked feature and mouseover feature that I will have to research some more.

@probins
Copy link
Contributor Author

probins commented Jul 7, 2015

that should fix it, but I'll take a look later today

@probins
Copy link
Contributor Author

probins commented Jul 7, 2015

yes, that fixes my issue, thanks. Only situation that might not work with this is if you have unmanaged layers included in the layer filter - not sure whether that's a realistic use case, though. :-)

@ahocevar
Copy link
Member

ahocevar commented Jul 7, 2015

I added documentation to make clear that the forEachFeatureAtPixel layer filter does not filter unmanaged layers.

@probins
Copy link
Contributor Author

probins commented Feb 9, 2016

This problem has returned.

Still the same situation of having 2 select interactions on the same layer/feature. Worked fine after this fix up to v3.11.2. Stops working with v3.12 (only just got around to upgrading, which is why I'm just reporting). There have been several versions of this, and I've got a bit confused as to what was changed where and why, but I think that 279eae1 (#4472) is the culprit.

Either interaction on its own works fine but, with both together, the 2nd one triggers the interaction but evt.selected is empty. There is no filter function, only a layer option restricting selection to the vector layers.

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 a pull request may close this issue.

4 participants