Skip to content

Commit

Permalink
fix: getfeatureinfo on grouplayers (origo-map#1659)
Browse files Browse the repository at this point in the history
* Fix issue origo-map#1614

getfeatureinfo on grouplayers

* Update getfeatureinfo.js

* Update getfeatureinfo.js

* Skip check if layer group is queryable
  • Loading branch information
jokd authored Jan 30, 2023
1 parent 2a1d9bf commit 8e3ce89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/featureinfo.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 12 additions & 10 deletions src/getfeatureinfo.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 8e3ce89

Please sign in to comment.