1
Vote

EditorWidget and TemplatePicker do not support group layers

description

When using group layers, certain controls, such as TemplatePicker and EditorWidget do not work as expected. In such cases, layers in group layers are not visible for use in the TemplatePicker control. I believe these controls do not traverse the full tree of layers, and instead just skip over group layers (as they are not feature layers).
 
A relatively simple solution would be to add a utility method to traverse the entire tree, such as in the following example:
 
    public static IEnumerable<TLayer> GetLayers<TLayer>(LayerCollection layers, bool recursive = true)
        where TLayer : Layer
    {
        if (layers == null)
            yield break;
 
        foreach (var layer in layers)
        {
            if (layer is TLayer)
            {
                yield return (TLayer)layer;
            }
 
            if (recursive && layer is GroupLayer)
            {
                var groupLayer = (GroupLayer)layer;
 
                foreach (var childLayer in GetLayers<TLayer>(groupLayer.ChildLayers, recursive))
                {
                    yield return childLayer;
                }
            }
        }
    }
 
This would also require a modification to the way the "LayerIds" property is handled. Instead of simply accepting layer ID's, it may accept a "path", such as in the format "GroupLayer\SubGroup\LayerId". This may require a slightly different approach than the code above, as the layer path should be checked at each level to determine of the layer meets the specified criteria.

comments