Skip to content

Commit

Permalink
fix: respect layers parameter in getFeatureInfoRequests (#1865)
Browse files Browse the repository at this point in the history
* respect layers parameter in getFeatureInfoRequests

* lint
  • Loading branch information
jokd authored Oct 31, 2023
1 parent e06b796 commit 754cb1a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
2 changes: 0 additions & 2 deletions src/featureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@ const Featureinfo = function Featureinfo(options = {}) {
const pixel = evt.pixel;
const map = viewer.getMap();
const coordinate = evt.coordinate;
const layers = viewer.getQueryableLayers();
const clientResult = getFeatureInfo.getFeaturesAtPixel({
coordinate,
clusterFeatureinfoLevel,
Expand All @@ -646,7 +645,6 @@ const Featureinfo = function Featureinfo(options = {}) {
if (clientResult !== false) {
getFeatureInfo.getFeaturesFromRemote({
coordinate,
layers,
map,
pixel
}, viewer)
Expand Down
42 changes: 24 additions & 18 deletions src/getfeatureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,27 +189,33 @@ function getGetFeatureInfoRequest({ layer, coordinate }, viewer) {

function getFeatureInfoRequests({
coordinate,
pixel
pixel,
layers
}, viewer) {
const imageFeatureInfoMode = viewer.getViewerOptions().featureinfoOptions.imageFeatureInfoMode || 'pixel';
const requests = [];
const queryableLayers = viewer.getLayersByProperty('queryable', true);
const layerGroups = viewer.getGroupLayers();
layerGroups.forEach(layerGroup => {
if (layerGroup.get('visible')) {
layerGroup.getLayersArray().forEach(layer => {
if ((layer.get('queryable'))) {
queryableLayers.push(layer);
}
});
} else {
layerGroup.getLayersArray().forEach(layer => {
if (layer.get('queryable') && ((layer.get('imageFeatureInfoMode') && layer.get('imageFeatureInfoMode') === 'always') || (!layer.get('imageFeatureInfoMode') && imageFeatureInfoMode === 'always'))) {
queryableLayers.push(layer);
}
});
}
});
let queryableLayers;
if (layers) {
queryableLayers = layers;
} else {
queryableLayers = viewer.getLayersByProperty('queryable', true);
const layerGroups = viewer.getGroupLayers();
layerGroups.forEach(layerGroup => {
if (layerGroup.get('visible')) {
layerGroup.getLayersArray().forEach(layer => {
if ((layer.get('queryable'))) {
queryableLayers.push(layer);
}
});
} else {
layerGroup.getLayersArray().forEach(layer => {
if (layer.get('queryable') && ((layer.get('imageFeatureInfoMode') && layer.get('imageFeatureInfoMode') === 'always') || (!layer.get('imageFeatureInfoMode') && imageFeatureInfoMode === 'always'))) {
queryableLayers.push(layer);
}
});
}
});
}

const imageLayers = queryableLayers.filter(layer => layer instanceof BaseTileLayer || layer instanceof ImageLayer);
imageLayers.forEach(layer => {
Expand Down

0 comments on commit 754cb1a

Please sign in to comment.