[Users] LegendGraphics in Layer Tree [Sec=Unclassified]
Miles Jordan
Miles.Jordan at aad.gov.au
Tue Jul 6 07:21:12 CEST 2010
Thanks Matt,
My layers are loading from a Ext.data.JsonStore so I didn't try 1). I tried 2) but couldn't get it to work the way that you mentioned.
With a little help from comments in the TreeLoader source and http://www.mail-archive.com/users@geoext.org/msg00336.html I got it to work.
In the end the loader for the LayerContainer looks like:
loader: {
createNode: function(attr) {
var layer = this.store.getById(attr.layer.id).get('layer');
var layer_name = layer.params.LAYERS;
attr.icon = wms + 'REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=' + layer_name;
return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
}
}
It works, but the way to get the layer name seems ugly - perhaps there is a nicer way. Anyway this will do for now!
Thanks,
Miles
Matt Priour wrote:
> To make the layer nodes themselves each have unique graphic icon, you
> can do
> 2 possible things.
> 1. Don't use an overlay layer container or other such preconfigured
> layer tree loader node type. Instead, use 'nodeType:"layerNode"' and
> give each layer node an 'icon' property (to put the legend graphic url
> directly in the tree configuration) or an 'iconCls' (to do it via CSS
> background images)
>
> 2. Go ahead and use one of the GeoExt layer tree loader node types and
> in the baseAttrs property of the loader, assign a renderer function or
> assign a function to the 'icon' attribute to allow you to calculate
> the icon path automattically
>
> If you just want to include a legend somewhere in the layertree panel,
> then you can use one of the GeoExt legend widgets for that.
>
> Matt Priour
> Kestrel Computer
>
> --------------------------------------------------
> From: "Miles Jordan" <Miles.Jordan at aad.gov.au>
> Sent: Monday, July 05, 2010 7:39 PM
> To: <users at geoext.org>
> Subject: Re: [Users] LegendGraphics in Layer Tree [Sec=Unclassified]
>
>> Miles Jordan wrote:
>>> Hi,
>>>
>>> Is it possible to put an icon representing each layer (legendgraphic)
>>> in the layer tree? I've been searching for a good example to no avail.
>>>
>>
>> I take it by the null response that it's not a straight forward thing
>> in GeoExt to have a layer switcher that also displays a legend. Is that
>> not a fundamental part of web mapping? I'm sure it can't be too hard,
>> but either way, I'd really appreciate it if somebody could let me know!
>> I just don't want to reinvent the wheel.
>>
>> Thanks,
>>
>> Miles
>>
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________
More information about the Users
mailing list