I'm trying to limit the features returned when I click on the map to just those in the endPoint layer:
endPoint = new ol.layer.Vector({ source: new ol.source.Vector({ features: endPoints //add an array of features }), }); map.addLayer(endPoint) Unfortunately, before this layer is even initialised, whilst clicking on features in other layers they are getting logged to the console. I feel like I'm using the correct syntax to limit the features to just those in the endPoint layer (forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2)) but I must be doing something wrong - if I try to return layer rather than feature it gives me a null value?
Is the issue that I need to name the layer somehow?
map.on('click', function(evt) { var pixel = map.getEventPixel(evt.originalEvent); var mapFeature = map.forEachFeatureAtPixel(pixel, function(feature, layer) { return feature; }, null, function(layer) { return layer === endPoint; }); console.log(mapFeature) }) Thanks
أكثر...
endPoint = new ol.layer.Vector({ source: new ol.source.Vector({ features: endPoints //add an array of features }), }); map.addLayer(endPoint) Unfortunately, before this layer is even initialised, whilst clicking on features in other layers they are getting logged to the console. I feel like I'm using the correct syntax to limit the features to just those in the endPoint layer (forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2)) but I must be doing something wrong - if I try to return layer rather than feature it gives me a null value?
Is the issue that I need to name the layer somehow?
map.on('click', function(evt) { var pixel = map.getEventPixel(evt.originalEvent); var mapFeature = map.forEachFeatureAtPixel(pixel, function(feature, layer) { return feature; }, null, function(layer) { return layer === endPoint; }); console.log(mapFeature) }) Thanks
أكثر...