Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: option "layer" for a TreeNode does not support a layer's name anymore #212

Open
Skrol29 opened this issue Nov 12, 2013 · 2 comments
Open

Comments

@Skrol29
Copy link

Skrol29 commented Nov 12, 2013

Hi GeoExt Team !

In GeoExt version "pre-2.0", the property "layer" of a TreeNode configuration could be a layer's name instead of a the Layer object itself.

That was a welcome shorthand when the LayerTree composition comes from a JSON string, like when the attached store has an Ajax data source.

My workaround for now is to add a listener in the LayerTree's configuration:

var options = {
    ...
    listeners: {
        beforeitemappend: function (_this, node) {
            if (node.data.layer && (typeof node.data.layer == 'string') ) {
                var x = my_application.my_map.getLayersByName(layer);
                if (x.length > 0) {
                    node.data.layer = x[0];
                }
            }
        }
    }
}

The regression seems bogus, nevertheless the feature is hotly appreciable.
I can suggest a fix if needed but the snippet in GeoExt version "pre-2.0" was ok.

Code where the layer is fetched from the node configuration:
File: "/src/GeoExt/tree/LayerNode.js", line:

    init: function(target) {

        this.target = target;
        var layer = target.get('layer');
@Skrol29
Copy link
Author

Skrol29 commented Nov 14, 2013

Can be fixed by issue #213 .

@marcjansen
Copy link
Member

#213 should be made a PR, I added a comment over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants