[Users] Customizing Layer Icons for a LayerContainer
Adam Ratcliffe
adam at prema.co.nz
Sat Jun 12 13:54:59 CEST 2010
Hi Eric,
Thanks, that's the solution I was looking for.
BTW the current release (v0.7) of GeoExt.data.LayerStore does not have the getByLayer() method I used this code instead:
this.store.getById(attr.layer.id)
which worked fine.
Cheers
Adam
On 12/06/2010, at 7:03 AM, Eric Lemoine wrote:
> 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