diff --git a/src/featureinfo.js b/src/featureinfo.js index 9df65f2a5..343c2b847 100644 --- a/src/featureinfo.js +++ b/src/featureinfo.js @@ -1,7 +1,6 @@ import Overlay from 'ol/Overlay'; import BaseTileLayer from 'ol/layer/BaseTile'; import ImageLayer from 'ol/layer/Image'; -import LayerGroup from 'ol/layer/Group'; import OGlide from './oglide'; import { Component, Modal } from './ui'; import Popup from './popup'; @@ -674,8 +673,10 @@ const Featureinfo = function Featureinfo(options = {}) { cursor = 'pointer'; } else { const layerArray = []; - const layerGroups = viewer.getQueryableLayers().filter(layer => layer instanceof LayerGroup); - if (layerGroups) { layerGroups.forEach(item => item.getLayersArray().forEach(element => layerArray.push(element))); } + const layerGroups = viewer.getGroupLayers(); + layerGroups.forEach(item => item.getLayersArray().forEach(element => { + if (element.get('queryable') && element.get('visible')) { layerArray.push(element); } + })); const layers = viewer.getQueryableLayers().filter(layer => layer instanceof BaseTileLayer || layer instanceof ImageLayer); if (layers) { layers.forEach(element => layerArray.push(element)); } for (let i = 0; i < layerArray.length; i += 1) { diff --git a/src/getfeatureinfo.js b/src/getfeatureinfo.js index a4fb6a6f5..7b87294ec 100644 --- a/src/getfeatureinfo.js +++ b/src/getfeatureinfo.js @@ -1,7 +1,6 @@ import EsriJSON from 'ol/format/EsriJSON'; import BaseTileLayer from 'ol/layer/BaseTile'; import ImageLayer from 'ol/layer/Image'; -import LayerGroup from 'ol/layer/Group'; import maputils from './maputils'; import SelectedItem from './models/SelectedItem'; @@ -184,19 +183,22 @@ function getFeatureInfoRequests({ const imageFeatureInfoMode = viewer.getViewerOptions().featureinfoOptions.imageFeatureInfoMode || 'pixel'; const requests = []; const queryableLayers = viewer.getLayersByProperty('queryable', true); - const layerGroups = queryableLayers.filter(layer => layer instanceof LayerGroup); - if (layerGroups) { - const visibleGroups = layerGroups.filter(group => group.get('visible') === true); - if (visibleGroups.length) { - visibleGroups.forEach(visibleGroup => visibleGroup.getLayersArray().forEach(layer => queryableLayers.push(layer))); + const layerGroups = viewer.getGroupLayers(); + layerGroups.forEach(layerGroup => { + if (layerGroup.get('visible')) { + layerGroup.getLayersArray().forEach(layer => { + if ((layer.get('queryable'))) { + queryableLayers.push(layer); + } + }); } else { - layerGroups.forEach(layerGroup => layerGroup.getLayersArray().forEach(layer => { - if ((layer.get('imageFeatureInfoMode')) && (layer.get('imageFeatureInfoMode') === 'always')) { + 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 => {