[Users] Tree, gx_layer and KML
Andreas Hocevar
ahocevar at opengeo.org
Mon Nov 16 13:17:43 CET 2009
Christian Spanring wrote:
> On Nov 15, 2009, at 9:14 AM, Eric Lemoine wrote:
>
>
>> On Sunday, November 15, 2009, Fabien <fabien.goblet at gmail.com> wrote:
>>
>>> You're right !
>>>
>> providing a reference to the layer should work equally (layer:sundials
>> in place of layer:"sundials")
>>
>
> I never got references to work in layer trees. When trying to do so, the script crashes/hangs my browser (Firefox, Safari) immediately (incl. Firebug, which doesn't give me any hint about the problem). I just reproduced that issue by adding a new layer to the GeoExt tree example and referencing it as "gx_layer" in the "treeConfig" layer tree.
>
That example shows how to configure a tree with pure JSON, and this is
why references do not work here:
var treeConfig = new OpenLayers.Format.JSON().write([...], true);
...
root: {
nodeType: "async",
// the children property of an Ext.tree.AsyncTreeNode is used to
// provide an initial set of layer nodes. We use the treeConfig
// from above, that we created with OpenLayers.Format.JSON.write.
children: Ext.decode(treeConfig)
},
If you want to use references, you have to configure your tree in JavaScript, not JSON:
var treeConfig = [...];
...
root: {
nodeType: "async",
// the children property of an Ext.tree.AsyncTreeNode is used to
// provide an initial set of layer nodes. We use the treeConfig
// from above.
children: treeConfig
},
This will of course break on-the-fly editing of the tree configuration.
Regards,
Andreas.
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list