Hi,
your GetLegendGraphic request string misses some required parameters ("STYLES"
at least, IIRC), and you probably want to remove "Asphalt" at the end of the
string.
Regards,
Andreas.
On Nov 23, 2010, at 15:16 , Andrew Stewart wrote:
> Thanks for the advice. I tried to use the code with my paramloader but it
> doesn't seem to be working, is there something I am missing? -
>
> layerList_Base = new GeoExt.tree.LayerNode({
> "layer": layer_Base,
> "isLeaf": true,
> "checked": false,
> "enableDD": true,
> "cls": "rootnode",
> "singleClickExpand": true,
> "listeners": {
> 'checkchange' : function(node, checked)
> {
> // If a parent node is unchecked, uncheck all the children
> if (node.getUI().isChecked()) {
> node.expand();
> }
> if (!node.getUI().isChecked())
> {
> node.collapse();
> }
> }
> },
> "loader": {
> "param": "LAYERS",
> createNode: function(attr) {
> attr.icon =
> "http://localhost/WebServices/Request.aspx?request=GetLegendGraphic&version=1.1.1&format=image/png&layer=Asphalt"+attr.text;
> return
> GeoExt.tree.LayerParamLoader.prototype.createNode.apply(this,arguments);
> }
>
> }
> });
>
>
> layerRoot_Legend.appendChild(layerList_Base);
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of
> Andreas Hocevar
> Sent: November 23, 2010 2:18 AM
> To: Andrew Stewart
> Cc: [email protected]
> Subject: Re: [Users] Question on using WMS GetLegendGraphic with a
> GeoExt.tree.LayerNode
>
> Hi,
>
> the easiest way is to customize your loader with a createNode method. Inside
> that method, you set the icon attribute to the location (GetLegendGraphic
> request) of your image.
>
> loader: {
> param: "LAYERS",
> createNode: function(attr) {
> attr.icon = "...&reqest=GetLegendGraphic&layers="+attr.text
> return GeoExt.tree.LayerParamLoader.prototype.createNode.apply(this,
> arguments);
> }
> }
>
> Regards,
> Andreas.
>
> On Nov 23, 2010, at 01:38 , Andrew Stewart wrote:
>
>> Sorry to reply so many times to my own post.. but I kinda figured this out.
>> Basically now I am setting the text property of each childnode after
>> expanding to the WMS GetLegendGraphic request and then contatonating that
>> with the text name of the node. Is there a better way to do this.. I am just
>> using the expand event and then redrawing the entire childnodes with new
>> icons.. can I do this before the nodes are even expanded?
>>
>>
>>
>>
>>
>>
>>
>>
>> From: [email protected] [[email protected]] On Behalf Of
>> Andrew Stewart [[email protected]]
>> Sent: November 22, 2010 4:22 PM
>> To: [email protected]
>> Subject: Re: [Users] Question on using WMS GetLegendGraphic with a
>> GeoExt.tree.LayerNode
>>
>> So I have tried to change the icon of each childNode after the expand event
>> like so -
>>
>>
>> 'expand' : {fn: function(node) {
>> var count = (node.childNodes.length -1);
>> while (count >= 0)
>> {node.childNodes[count].setIcon("../images/minus.png");
>> count -=1;
>> }
>> }}
>>
>> But this does not seem to work, anything else I can try?
>>
>>
>>
>> ________________________________
>> From: [email protected] [mailto:[email protected]] On Behalf
>> Of Andrew Stewart
>> Sent: November 22, 2010 3:51 PM
>> To: [email protected]
>> Subject: [Users] Question on using WMS GetLegendGraphic with a
>> GeoExt.tree.LayerNode
>>
>> Is it possible to show a legend graphic which is returned from my WMS
>> GetLegendGraphic request next to each item on the LayerNode after it is
>> expanded? (or before.. Or whenever as long as it shows).
>>
>> I declare my layernode like so -
>>
>> //Trails layerList
>> layerList_Trails = new GeoExt.tree.LayerNode({
>> "layer": layer_Trails,
>> "isLeaf": false,
>> "checked": false,
>> "enableDD": true,
>> "cls": "rootnode",
>> "singleClickExpand": true,
>> "listeners": {
>> 'checkchange' : function(node, checked)
>> {
>> // If a parent node is unchecked, uncheck all the children
>> if (node.getUI().isChecked()) {
>> node.expand();
>> }
>> if (!node.getUI().isChecked())
>> {
>> node.collapse();
>> }
>> }
>> },
>> "loader": {
>> "param": "LAYERS"
>> }
>> });
>>
>> Which is added to my root -
>> layerRoot_Legend.appendChild(layerList_Trails);
>>
>> And then my treepanel
>>
>> var layerRoot_Legend = new Ext.tree.TreeNode({
>> enableDD: true,
>> text: "All Legend Items",
>> loaded: true,
>> expanded: true
>> });
>>
>> var layerTree_Legend = new Ext.tree.TreePanel({
>> title: '',
>> root: layerRoot_Legend,
>> enableDD: true,
>> applyLoader: true,
>> rootVisible: false
>> });
>>
>>
>> Except previously when I declared my layers individually I had put an <img>
>> tag with the right layer next to each.. But now I am declaring them in
>> groups like -
>> //Trails Group
>> var layer_Trails = new OpenLayers.Layer.WMS("<img
>> src='http://localhost/WebService/Request.aspx?request=GetLegendGraphic&version=1.1.1&format=image/png&layer=Asphalt'
>> alt=''/>Trails", "http://localhost/WebService/Request.aspx",
>> {
>> layers: ['Onstreet_Bike_Route', 'Mountain_-_Stunt_Biking',
>> 'Equestrian', 'Gravel_or_Shale', 'Asphalt'],
>> VERSION: "1.1.1",
>> transparent: true
>> },
>> { isBaseLayer: false,
>> singleTile: true,
>> visibility: false,
>> buffer: 1,
>> ratio: 1
>> }
>> But this only puts the image on the actual group name and I need it to be
>> beside each legend entry when it is expanded. Is there a place somewhere I
>> can stick this image tag and either hard code the layer name or have it be
>> returned from the childNodes of the tree and get it to show this image
>> beside each childNode? Appreciate any assistance!
>>
>>
>>
>> ________________________________
>> This e-mail is intended for the original recipient(s) only. If you have
>> received it in error, please advise the sender and delete this message.
>>
>> ________________________________
>> [This message has been scanned for security content threats and viruses.]
>>
>> [The City of Red Deer I.T. Services asks that you please consider the
>> environment before printing this e-mail.]
>>
>> ________________________________
>> This e-mail is intended for the original recipient(s) only. If you have
>> received it in error, please advise the sender and delete this message.
>>
>> ________________________________
>> [This message has been scanned for security content threats and viruses.]
>>
>> [The City of Red Deer I.T. Services asks that you please consider the
>> environment before printing this e-mail.]
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> [email protected]
>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
> [This message has been scanned for security content threats and viruses.]
>
> [The City of Red Deer I.T. Services asks that you please consider the
> environment before printing this e-mail.]
>
>
>
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users