<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi there,<br><br>I have some doubts about gx_wmslegend and WMSCapabilitiesStore, I would really appreciate some support to understand the source of the error and solve the error I get when they are combined. When I use this code (code in bold means for comparison between codes):<br><br> // create a new WMS capabilities store<br> store = new GeoExt.data.WMSCapabilitiesStore({<br> url: "/mmss?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1"<br> });<br> store.load();<br><br> // create a grid to display records from the store<br> addLayerGrid = new Ext.grid.GridPanel({<br> autoHeight: true,<br> hideBorders: true,<br> border: false,<br> frame: false,<br> columnLines: true,<br> viewConfig: {<br> scrollOffset: 0<br> },<br> store: store,<br> cm: new Ext.grid.ColumnModel([<br> {id: "idTitle", header: "Layer", dataIndex: "title", width: 155},<br> {id: "idAbstract", header: "Brief description", dataIndex: "abstract", width: 255}<br> ]),<br> autoExpandColumn: "idAbstract",<br> bbar: ["->", {<br> handler: function() {<br> addLayerGrid.getSelectionModel().each(function(record) {<br> var copy = record.copy();<br> mapPanel.layers.add(copy);<br> mapPanel.map.setCenter(<br> OpenLayers.Bounds.fromArray(copy.get("llbbox"))<br> );<br> });<br> }<br> }]<br> });<br><br> <b>root = new GeoExt.tree.LayerContainer({<br> layerStore: mapPanel.layers,<br> leaf: false,<br> expanded: true<br> });</b><div><b><br> removeLayerTreeLegend = new Ext.tree.TreePanel({<br> autoHeight: true,<br> border: false,<br> lines: false,<br> enableDD: true,<br> rootVisible: false,<br> root: root,<br> bbar: ["->", {<br> handler: function() {<br> var node = removeLayerTreeLegend.getSelectionModel().getSelectedNode();<br> if (node && node.layer instanceof OpenLayers.Layer.WMS) {<br> mapPanel.map.removeLayer(node.layer);<br> }<br> }<br> }]<br> });</b><br><br>Things work great as in the GeoExt 1.1 examples. But if I use instead this combination I get an error (see below code):<br><br> // custom layer node UI class<br> var LayerNodeUI = Ext.extend(<br> GeoExt.tree.LayerNodeUI,<br> new GeoExt.tree.TreeNodeUIEventMixin()<br> );<br><br> // create a new WMS capabilities store<br> store = new GeoExt.data.WMSCapabilitiesStore({<br> url: "/mmss?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1"<br> });<br> store.load();<br><br> // create a grid to display records from the store<br> addLayerGrid = new Ext.grid.GridPanel({<br> autoHeight: true,<br> hideBorders: true,<br> border: false,<br> frame: false,<br> columnLines: true,<br> viewConfig: {<br> scrollOffset: 0<br> },<br> store: store,<br> cm: new Ext.grid.ColumnModel([<br> {id: "idTitle", header: "Layer", dataIndex: "title", width: 155},<br> {id: "idAbstract", header: "Brief description", dataIndex: "abstract", width: 255}<br> ]),<br> autoExpandColumn: "idAbstract",<br> bbar: ["->", {<br> handler: function() {<br> addLayerGrid.getSelectionModel().each(function(record) {<br> var copy = record.copy();<br> mapPanel.layers.add(copy);<br> mapPanel.map.setCenter(<br> OpenLayers.Bounds.fromArray(copy.get("llbbox"))<br> );<br> });<br> }<br> }]<br> });<br><br> <b>removeLayerTreeLegend = new Ext.tree.TreePanel({<br> autoHeight: true,<br> border: false,<br> lines: false,<br> enableDD: true,<br> rootVisible: false,<br> plugins: [{<br> ptype: "gx_treenodecomponent"<br> }],<br> loader: {<br> applyLoader: false,<br> uiProviders: {<br> "custom_ui": LayerNodeUI<br> }<br> },<br> root: {<br> nodeType: "gx_layercontainer",<br> loader: {<br> baseAttrs: {<br> uiProvider: "custom_ui"<br> },<br> createNode: function(attr) {<br> attr.component = {<br> xtype: "gx_wmslegend",<br> baseParams: {format: "image/png"},<br> layerRecord: mapPanel.layers.getByLayer(attr.layer),<br> showTitle: false,<br> cls: "legend"<br> }<br> return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);<br> }<br> }<br> },<br> bbar: ["->", {<br> text: OpenLayers.i18n('Layering.removeButton'),<br> handler: function() {<br> var node = removeLayerTreeLegend.getSelectionModel().getSelectedNode();<br> if (node && node.layer instanceof OpenLayers.Layer.WMS) {<br> mapPanel.map.removeLayer(node.layer);<br> }<br> }<br> }]<br> });</b><br><br>This error message appears related to 'LAYERS' is undefined in WMSlegend.js:<br><br> Uncaught TypeError: Cannot read property 'LAYERS' of undefined<br><br>pointing to:<br><br> layerNames = [layer.params.LAYERS].join(",").split(",");<br><br>in WMSlegend.js line 184.<div><br></div><div><a href="http://i.stack.imgur.com/CHa4v.png" target="_blank">http://i.stack.imgur.com/CHa4v.png</a><br><div><br></div><div>I understand that LAYERS is provided by `store.load` above, is this correct? if so, what is missing?<br><br>I'd appreciate your support on this, thanks in advance,<br></div></div></div><div><br></div><div>Gery</div>                                            </div></body>
</html>