[Users] Customizing Layer Icons for a LayerContainer
Eric Lemoine
eric.lemoine at camptocamp.com
Fri Jun 11 21:03:16 CEST 2010
On Fri, Jun 11, 2010 at 4:57 AM, Adam Ratcliffe <adam at prema.co.nz> wrote:
> Hi,
>
> I have a TreePanel with a GeoExt.tree.LayerContainer like the one in
> this example: http://dev.geoext.org/trunk/geoext/examples/layercontainer.html
>
> For each layer displayed in the Layer Tree I would like to use an icon
> based upon a property of the underlying LayerRecord. I imagine this
> is a fairly common use case but I'm struggling to understand how to do
> it. The best I've managed so far is to change the icon for all layers
> to the same icon e.g.
>
> root: new GeoExt.tree.LayerContainer({
> text: 'Map Layers',
> loader: {
> baseAttrs: {
> iconCls: 'icon_layer',
> store: layerStore
> }
> },
> layerStore: layerStore,
> leaf: false,
> expanded: true
> }), expanded: true
> }
Hi.
You can create a layer loader instance that overrides createNode:
var loader = GeoExt.tree.LayerLoader({
createNode: function(attr) {
attr.iconCls = this.store.getByLayer(attr.layer).get("icon");
GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
}
});
and give this loader to the layer container:
root: new GeoExt.tree.LayerContainer({
loader: loader,
...
})
Hope it'll work for you.
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list