[Users] GeoExt.data.WMSCapabilitiesStore with gx_wmslegend
Gery .
gamejihou at hotmail.com
Sat Dec 20 12:16:57 CET 2014
Hi there,
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):
// create a new WMS capabilities store
store = new GeoExt.data.WMSCapabilitiesStore({
url: "/mmss?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1"
});
store.load();
// create a grid to display records from the store
addLayerGrid = new Ext.grid.GridPanel({
autoHeight: true,
hideBorders: true,
border: false,
frame: false,
columnLines: true,
viewConfig: {
scrollOffset: 0
},
store: store,
cm: new Ext.grid.ColumnModel([
{id: "idTitle", header: "Layer", dataIndex: "title", width: 155},
{id: "idAbstract", header: "Brief description", dataIndex: "abstract", width: 255}
]),
autoExpandColumn: "idAbstract",
bbar: ["->", {
handler: function() {
addLayerGrid.getSelectionModel().each(function(record) {
var copy = record.copy();
mapPanel.layers.add(copy);
mapPanel.map.setCenter(
OpenLayers.Bounds.fromArray(copy.get("llbbox"))
);
});
}
}]
});
root = new GeoExt.tree.LayerContainer({
layerStore: mapPanel.layers,
leaf: false,
expanded: true
});
removeLayerTreeLegend = new Ext.tree.TreePanel({
autoHeight: true,
border: false,
lines: false,
enableDD: true,
rootVisible: false,
root: root,
bbar: ["->", {
handler: function() {
var node = removeLayerTreeLegend.getSelectionModel().getSelectedNode();
if (node && node.layer instanceof OpenLayers.Layer.WMS) {
mapPanel.map.removeLayer(node.layer);
}
}
}]
});
Things work great as in the GeoExt 1.1 examples. But if I use instead this combination I get an error (see below code):
// custom layer node UI class
var LayerNodeUI = Ext.extend(
GeoExt.tree.LayerNodeUI,
new GeoExt.tree.TreeNodeUIEventMixin()
);
// create a new WMS capabilities store
store = new GeoExt.data.WMSCapabilitiesStore({
url: "/mmss?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1"
});
store.load();
// create a grid to display records from the store
addLayerGrid = new Ext.grid.GridPanel({
autoHeight: true,
hideBorders: true,
border: false,
frame: false,
columnLines: true,
viewConfig: {
scrollOffset: 0
},
store: store,
cm: new Ext.grid.ColumnModel([
{id: "idTitle", header: "Layer", dataIndex: "title", width: 155},
{id: "idAbstract", header: "Brief description", dataIndex: "abstract", width: 255}
]),
autoExpandColumn: "idAbstract",
bbar: ["->", {
handler: function() {
addLayerGrid.getSelectionModel().each(function(record) {
var copy = record.copy();
mapPanel.layers.add(copy);
mapPanel.map.setCenter(
OpenLayers.Bounds.fromArray(copy.get("llbbox"))
);
});
}
}]
});
removeLayerTreeLegend = new Ext.tree.TreePanel({
autoHeight: true,
border: false,
lines: false,
enableDD: true,
rootVisible: false,
plugins: [{
ptype: "gx_treenodecomponent"
}],
loader: {
applyLoader: false,
uiProviders: {
"custom_ui": LayerNodeUI
}
},
root: {
nodeType: "gx_layercontainer",
loader: {
baseAttrs: {
uiProvider: "custom_ui"
},
createNode: function(attr) {
attr.component = {
xtype: "gx_wmslegend",
baseParams: {format: "image/png"},
layerRecord: mapPanel.layers.getByLayer(attr.layer),
showTitle: false,
cls: "legend"
}
return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
}
}
},
bbar: ["->", {
text: OpenLayers.i18n('Layering.removeButton'),
handler: function() {
var node = removeLayerTreeLegend.getSelectionModel().getSelectedNode();
if (node && node.layer instanceof OpenLayers.Layer.WMS) {
mapPanel.map.removeLayer(node.layer);
}
}
}]
});
This error message appears related to 'LAYERS' is undefined in WMSlegend.js:
Uncaught TypeError: Cannot read property 'LAYERS' of undefined
pointing to:
layerNames = [layer.params.LAYERS].join(",").split(",");
in WMSlegend.js line 184.
http://i.stack.imgur.com/CHa4v.png
I understand that LAYERS is provided by `store.load` above, is this correct? if so, what is missing?
I'd appreciate your support on this, thanks in advance,
Gery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20141220/c9302c6d/attachment.htm
More information about the Users
mailing list