<p>Hi François,</p>
<p>I just tried it with the following code, but there are no nodes listed in the tree.<br />Could the url parameter be the problem?: http://localhost:8080/geoserver/wms</p>
<p>var root = new Ext.tree.AsyncTreeNode({<br /> text: 'All Layers', <br /> loader: new GeoExt.tree.WMSCapabilitiesLoader({<br /> url: 'http://localhost:8080/geoserver/wms', <br /> layerOptions: {buffer: 0, singleTile: true, ratio: 1},<br /> layerParams: {'TRANSPARENT': 'TRUE'}, <br /> // customize the createNode method to add a checkbox to nodes <br /> createNode: function(attr) {<br /> attr.checked = attr.leaf ? false : undefined; <br /> return GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]); <br /> } <br /> }) <br />});</p>
<p>tree = new Ext.tree.TreePanel({ <br /> root: root,<br /> region: 'west',<br /> width: 250,<br /> listeners: { <br /> // Add layers to the map when ckecked, remove when unchecked.<br /> // Note that this does not take care of maintaining the layer order on the map.<br /> 'checkchange': function(node, checked) {<br /> if (checked === true) {<br /> mapPanel.map.addLayer(node.attributes.layer);<br /> } else {<br /> mapPanel.map.removeLayer(node.attributes.layer);<br /> }<br /> } <br /> }<br />});</p>
<p>regards, Chris</p>
<p>On Thu, 18 Apr 2013 10:25:19 -0400, "Valiquette,Francois [Montreal]" <Francois.Valiquette@ec.gc.ca> wrote:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%"><!-- html ignored --><!-- head ignored --><!-- meta ignored --><!-- meta ignored -->
<div class="WordSection1">
<p class="MsoSalutation">Hello Chris,<!-- o ignored --></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"><!-- o ignored --> </span></p>
<p class="MsoBodyText">Yes you can, you need to make a query on your server to get the GetCapabilities XML (a list of all the available layers and options).<!-- o ignored --></p>
<p class="MsoBodyText">The GeoExt.data.WMSCapabilitiesStore can make the query for you by giving it an URL. Then, it will return you a set of records. Afterward with the records, you can generate manually a Tree for a greater flexibility.<!-- o ignored --></p>
<p class="MsoBodyText">Otherwise, I think you can use GeoExt.tree.WMSCapabilitiesLoader to generate the Tree automatically for you. <!-- o ignored --></p>
<p class="MsoBodyText"><!-- o ignored --> </p>
<p class="MsoBodyText">Here is an exemple of a valid XML file :<!-- o ignored --></p>
<p class="MsoBodyText">http://api.geoext.org/1.1/examples/data/wmscap.xml<!-- o ignored --></p>
<p class="MsoBodyText"><br />François<!-- o ignored --></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"><!-- o ignored --> </span></p>
<div style="border: none; border-top: solid #B5C4DF 1.0pt; padding: 3.0pt 0cm 0cm 0cm;">
<p class="MsoNormal"><strong><span style="font-size: 10.0pt; font-family: 'Tahoma','sans-serif';">De :</span></strong><span style="font-size: 10.0pt; font-family: 'Tahoma','sans-serif';"> users-bounces@geoext.org [mailto:users-bounces@geoext.org] <strong>De la part de</strong> Christoph Mayrhofer<br /><strong>Envoyé :</strong> 18 avril 2013 10:05<br /><strong>À :</strong> users@geoext.org<br /><strong>Objet :</strong> [Users] Add all geoserver layers automatically<!-- o ignored --></span></p>
</div>
<p class="MsoNormal"><!-- o ignored --> </p>
<p>Hi,<!-- o ignored --></p>
<p>I saw some examples that had a List of available layers and a button that you could click to add a selected layers to the map.<br />Is it possible to have all layers on a Geoserver instance automatically added to the map.<br />This would eliminate the need to change the JS code when a new layer is added to Geoserver.<!-- o ignored --></p>
<p>regards, Chris<!-- o ignored --></p>
<div>
<p class="MsoNormal"> <!-- o ignored --></p>
</div>
</div>
</blockquote>
<div> </div>