I can't find a way to go from a feature in a selection event to a layer that it may be a part of without traversing all the features of all my map layers, or storing an artificial layer ID within every feature at creation. Is this just not possible yet?
ol.js 3.7.0 ol.interaction.Selection -> click -> callback( event ){ event.selected[0] }
In another part of my app, I would like to go from the feature to the layer to determine the style being used on the feature, specifically whether or not it's visible.
ol.Feature.getStyle() || ol.Feature -> (layer?) -> getStyle()
In Openlayers 4 -
map.forEachFeatureAtPixel
can be used to get at the parent layer of each feature.See code snippet here: https://stackoverflow.com/a/50415743/2288488
You could try with the filter function:
UPDATE
I came up with this prototypied method, it does the job:
http://jsfiddle.net/jonataswalker/r242y7ke/