Thank you Andres for your reply. This line:<br><br>attr.iconCls = "your_icon_class_here";<br><br>I know by default the gx-tree-layer-icon class is called. But I am not sure how to create my own :?. Also where is this gx-tree-layer-icon located? Maybe if I look at the class code I'll get it. Is there a way that I can have the iconCls just point to an image file? <br>
<br>I ended up using layer containers instead and now I am worried that I won't be able to customize each node :( Am I right about this? Here is my tree structure:<br><br>var layerRoot = new Ext.tree.TreeNode({<br> text: "All Layers",<br>
expanded: true<br> });<br><br>var tibNaturalLayers = new GeoExt.data.LayerStore({<br> map: map,<br> initDir: 0,<br> layers: [tib_villages, tib_rivers, tib_lakes, tib_grazing, tib_glaciers]<br>
});<br><br>layerRoot.appendChild(new GeoExt.tree.OverlayLayerContainer({<br> text: "Natural Selection (Tibetan trans)",<br> layerStore: tibNaturalLayers,<br> expanded: false,<br>
loader: {param: "LAYERS"}<br> }));<br><br>Thanks for all the support :)<br><br>elshae<br><br><br><div class="gmail_quote">On Thu, Sep 23, 2010 at 4:10 AM, Andreas Hocevar <span dir="ltr"><<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br>
<br>
the easiest thing to do is indeed just create one WMS layer:<br>
<br>
var villages = new OpenLayers.Layer.WMS(<br>
"Villages",<br>
<div class="im"> "<a href="http://10.0.102.11:8080/geoserver/wms" target="_blank">http://10.0.102.11:8080/geoserver/wms</a>", {<br>
</div> layers: 'cite:tib_townships,cite:tib_villages,cite:chn_villages',<br>
<div class="im"> transparent: true<br>
}, {<br>
isBaseLayer: false,<br>
displayInLayerSwitcher: true<br>
}<br>
</div>);<br>
<br>
Then, you could have an object for your options:<br>
<br>
var options = {<br>
"cite:tib_townships": {visibility: true, text: "Townships (Tibetan trans)"},<br>
"cite:tib_villages": {visibility: true, text: "Villages (Tibetan trans)"},<br>
"cite:chn_villages": {visibility: false, text: "Villages (Chinese trans)"}<br>
};<br>
<br>
Now in your tree, add the node for the WMS layer, and configure a loader with a custom createNode method that applies your options:<br>
<div class="im"><br>
layerRoot.appendChild(new GeoExt.tree.LayerNode({<br>
</div> layer: villages,<br>
isLeaf: false,<br>
loader: {<br>
param: "LAYERS",<br>
createNode: function(attr) {<br>
attr.layer.setVisibility(options[<a href="http://attr.layer.name" target="_blank">attr.layer.name</a>].visibility);<br>
attr.text = options[<a href="http://attr.layer.name" target="_blank">attr.layer.name</a>].text;<br>
attr.iconCls = "your_icon_class_here";<br>
GeoExt.tree.LayerParamLoader.prototype.createNode.call(this, attr);<br>
}<br>
}<br>
});<br>
<br>
The iconCls is for your custom icon. See the ExtJS documentation for Ext.tree.TreeNode for an explanation.<br>
<br>
This should cover about all you were asking.<br>
<br>
Regards,<br>
Andreas.<br>
<div><div></div><div class="h5"><br>
<br>
<br>
On Sep 22, 2010, at 19:37 , IT Intern wrote:<br>
<br>
> I sincerely apologize about the previous emails :(, they were sent by accident...<br>
><br>
> Hello GeoExt List,<br>
><br>
> I am new to GeoExt and I am grateful such a library has been created. Now I am trying to make a layer tree for my map browser. I got some ideas on how to create a general one, but there are some options I'd like to have that I cannot find. I do not know if it is because they do not exist or I am just unaware.<br>
><br>
> Here's what I'd like to do:<br>
><br>
> 1. I'd like to be able to have a few layers declared by variables as such:<br>
><br>
> var tib_townships = new OpenLayers.Layer.WMS(<br>
> "Townships (Tibetan trans)", "<a href="http://10.0.102.11:8080/geoserver/wms" target="_blank">http://10.0.102.11:8080/geoserver/wms</a>", {layers: 'cite:tib_townships', transparent: true}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}<br>
> );<br>
><br>
> var chn_villages = new OpenLayers.Layer.WMS(<br>
> "Villages (Chinese trans)", "<a href="http://10.0.102.11:8080/geoserver/wms" target="_blank">http://10.0.102.11:8080/geoserver/wms</a>", {layers: 'cite:chn_villages', transparent: true}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: false}<br>
> );<br>
><br>
> var tib_villages = new OpenLayers.Layer.WMS(<br>
> "Villages (Tibetan trans)", "<a href="http://10.0.102.11:8080/geoserver/wms" target="_blank">http://10.0.102.11:8080/geoserver/wms</a>", {layers: 'cite:tib_villages', transparent: true}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}<br>
> );<br>
><br>
> and then I'd like to be able to add these layers to a single node:<br>
><br>
> var layerRoot = new Ext.tree.TreeNode({<br>
> text: "All Layers",<br>
> expanded: true<br>
> });<br>
><br>
> layerRoot.appendChild(new GeoExt.tree.LayerNode({<br>
> text: "Tibetan Villages",<br>
> layer: tib_villages, //RIGHT HERE, is there a way to add all three layers here using those variables???<br>
> loader: {param: "LAYERS"},<br>
> expanded: true<br>
> }));<br>
><br>
> I know my other option is to create a Openlayer WMS with all three layers in it sort of as a group, but I run into the same problem there that I am unable to add these variables but have to add the layers directly from the wms and then they do not have the options I have set in my code :-/<br>
><br>
><br>
> 2. I'd also like to be able to change the names that appear for the layers that are in the nodes. Instead of the wms store:layer, I'd like something custom as "my layer". Is there any property for this anywhere???<br>
><br>
> 3. I'd like to change the icons of the default layer tree. Maybe instead of folders etc, something like my own image etc..<br>
><br>
> I appreciate all the feedback. I have been struggling with layer trees and I would really like to do something awesome with them for my app.<br>
><br>
> Thanks,<br>
><br>
> elshae<br>
><br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
> <a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
<br>
</font></blockquote></div><br>