Add layer also for programmatically selected features

This commit is contained in:
Andreas Hocevar
2021-12-21 08:23:56 +01:00
parent e5a32f533e
commit 4f7cadd17d
4 changed files with 62 additions and 6 deletions

View File

@@ -664,6 +664,25 @@ class PluggableMap extends BaseObject {
return features;
}
/**
* Get all layers from all layer groups.
* @return {Array<import("./layer/Layer.js").default>} Layers.
*/
getAllLayers() {
const layers = [];
function addLayersFrom(layerGroup) {
layerGroup.forEach(function (layer) {
if (layer instanceof LayerGroup) {
addLayersFrom(layer.getLayers());
} else {
layers.push(layer);
}
});
}
addLayersFrom(this.getLayers());
return layers;
}
/**
* Detect layers that have a color value at a pixel on the viewport, and
* execute a callback with each matching layer. Layers included in the