How can I get all child layers of a given layer group in Openlayers?
I go as far as establishing that a given layer is in fact a group, but then I get stumped:
// Handle visibility control
$('i').on('click', function() {
var layername = $(this).closest('li').data('layerid');
var layer = findBy(map.getLayerGroup(), 'name', layername);
var flagGroup = layer instanceof ol.layer.Group;
if (flagGroup) {
...
}
});
Answer
childLayers = layer.getLayers()
https://openlayers.org/en/latest/apidoc/ol.layer.Group.html#getLayers
No comments:
Post a Comment