Created
September 5, 2015 18:56
-
-
Save geographika/d04ff102b1803042b9fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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