Skip to content

Instantly share code, notes, and snippets.

@geographika
Created September 5, 2015 18:56
Show Gist options
  • Save geographika/d04ff102b1803042b9fb to your computer and use it in GitHub Desktop.
Save geographika/d04ff102b1803042b9fb to your computer and use it in GitHub Desktop.
/**
* @require OpenLayers/Layer.js
*/
(function () {
/**
An extended overlay container node, which automatically turns child layers on and off
*/
Ext.define('GeoExt.tree.ParameterLayerContainer', {
extend: 'GeoExt.tree.OverlayLayerContainer',
alias: 'plugin.parameterlayercontainer',
createParameterLayer: function (layerTitle, expanded) {
if (expanded === undefined) {
expanded = false;
}
var layerStore = this.mapPanel.layers;
var idx = layerStore.findExact("text", layerTitle);
if (idx === -1) {
console.warn("Layer with title " + layerTitle + " not found");
return;
}
var rec = layerStore.getAt(idx);
var layer = rec.getLayer();
var iconCls = rec.get("iconCls");
var parameters = rec.get("parameters").reverse();
var aliases = rec.get("parameterAliases").reverse();
var parameterName = rec.get("parameterName");
var params = {};
params[parameterName] = parameters;
layer.mergeNewParams(params);
var node = {
nodeType: "gx_layer",
expanded: false,
layer: layer,
loader: {
//delimiter: ",",
param: parameterName,
baseAttrs: {
iconCls: iconCls
},
createNode: function (attr) {
var idx = attr.allItems.indexOf(attr.item);
attr.text = aliases[idx];
// create the node as normal, but modify the text properties
var node = GeoExt.tree.LayerParamLoader.prototype.createNode.call(this, attr);
//node.text = node.text;
return node;
}
}
};
node.text = rec.get("text");
return node;
},
constructor: function (config) {
this.callParent([config]);
// TODO layernode no longer has events since update to GeoExt2
// http://geoext.github.io/geoext2/docs/source/LayerNode.html#GeoExt-tree-LayerNode
//this.on({
// "checkchange": this.enableNodes,
// scope: this
//});
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment