I have a map with some vector layers that deliver popups when the user clicks on the markers. I use a forEachFeatureAtPixel function to identify these layers. However, there are also several background layers which should do nothing if you click on them. After looking through this forum for methods, I am able to exclude one layer from the function, but how would I exclude several layers?
Background1 and background2 are the layers that should not deliver any popups. My code is like this:
var background1 = new ol.layer.Vector...
var background2 = new ol.layer.Vector...
var feature = map.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
if (layer != background1) return feature;
});
if (feature) {
//etc.
That works fine, but I also want to exclude background2. I thought I could write "if (layer != background1 || background2) return feature;" but that doesn't work. What should I do?
||
and not&&
. I mean in terms of logic you want to exclude these two layers, right?. If yes, It should beif (layer != background1 && layer != background2)
– pavlos Jan 25 '17 at 7:49