-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Select interaction ignores layer filter for feature overlays #2940
Comments
The draw interaction uses a FeatureOverlay when actually drawing. If you use a specific layer/source as where the draw interaction persists the drawn features you will be filter out that layer/source from the selection. |
Currently if you have Select and Draw interactions on a map, Select grabs/selects unfinished features that are just being drawn... there might be a use case for that, but as a non-overridable default... I'm tempted to call it a bug. I'm not suggesting that you modify the Map.forEachFeatureAtPixel - although that might also make sense as you can always make a filter that accepts "null layer" - but the callback function given to it by Select interaction. That callback function(feature, layer) uses array.indexOf to check if given feature is already selected or not, i.e. if it is on Select's own FeatureOverlay. As the layer parameter is null for features from a FeatureOverlay, you could optimise that check to happen only for overlay features. For not-yet-selected features, I think, it would make sense to use given layerFilter_ so that it (Select) would not unintentionally grab features from other interactions' internal FeatureOverlays. |
A PR would be ideal to understand what you need/suggest. Thanks. |
I've written an example that may illustrate the issue. In this example, we have two layers that are "unmanaged". The select interaction is configured with a |
In the tests (https://github.com/openlayers/ol3/blob/master/test/spec/ol/renderer/canvas/canvasmaprenderer.test.js#L49), it's clearly written that forEachFeatureAtPixel will always return features from the unmanaged layers. 1 - It should be documented in the API doc. |
And |
OK. Thanks. |
@pgiraud So I guess the problem is related to the Select interaction itself using an unmanaged layer for drawing selected features. If that unmanaged layer is filtered out then the selected features won't be returned by |
See #4143. |
Map.forEachFeatureAtPixel is called for all features of a feature overlay regardless of layer filter. I have a couple of layers containing different kind of editable information and use Draw (polygons) for one and Select/Modify (points) for another. I try to target Select to the layer containing the relevant points with layers option, but as Draw uses feature overlay, Select grabs those polygons immediately.
Would it be possible to use layerFilter also in the function(feature, layer) -argument of the map.forEachFeatureAtPixel? One can always supply a filter that accepts null-layer, but without it I see no way to skip feature overlays.
Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: