Hi all,
I add 'groupName' property for each layer. And I want to layer display in a
group. I don't use group layer of wms layer because I want to the layer can
be drapped to change it's z-index.
I write a class:
/**
* @author DinhToan
*/
Ext.ns("aic", "aic.map");
aic.map.GroupLayer = Ext.extend(GeoExt.tree.LayerContainer, {
groupName: "Group name",
constructor: function(config) {
config = Ext.applyIf(config || {}, {
text: "Group name",
groupName: "Group name",
loader: {}
});
config.loader = Ext.applyIf(config.loader, {
baseAttrs: Ext.applyIf(config.loader.baseAttrs || {}, {
iconCls: 'gx-tree-baselayer-icon'
}),
filter: function(record) {
var layer = record.getLayer();
return layer.displayInLayerSwitcher === true &&
layer.groupName === config.groupName;
}
});
aic.map.GroupLayer.superclass.constructor.call(this, config);
},
/** private: method[recordIndexToNodeIndex]
* :param index: ``Number`` The record index in the layer store.
* :return: ``Number`` The appropriate child node index for the record.
*/
recordIndexToNodeIndex: function(index) {
var store = this.loader.store;
var count = store.getCount();
var nodeCount = this.childNodes.length;
var nodeIndex = -1;
for(var i=count-1; i>=0; --i) {
if(this.loader.filter(store.getAt(i)) === true) {
++nodeIndex;
if(index === i || nodeIndex > nodeCount-1) {
break;
}
}
}
return nodeIndex;
}
});
Ext.tree.TreePanel.nodeTypes.gx_grouplayercontainer = aic.map.GroupLayer;
And I add two group to tree Panel,
var tree = new Ext.tree.TreePanel({
border: false,
animate: true,
useArrows: true,
loader: new Ext.tree.TreeLoader({
applyLoader: true,
uiProviders: {
layerNodeUI: aic.tree.LayerNodeUIOpacity
}
}),
root: {
nodeType: "async",
allowDrop: false,
children: layerGroupNodes //array with two group
},
enableDD: true,
rootVisible: false,
lines: false
});
But it false, tree layer display correct, but an error occur:
1.
2. Object [Node xnode-67] has no method 'recordIndexToNodeIndex'
1.
Ext.extend.onStoreAddGeoExt.js:110<http://localhost/aic40/js/geoext/GeoExt.js>
2. (anonymous
function)ext-base.js:7<http://localhost/aic40/js/ext/adapter/ext/ext-base.js>
3. h.Event.fireext-all.js:7<http://localhost/aic40/js/ext/ext-all.js>
4.
h.Observable.fireEventext-all.js:7<http://localhost/aic40/js/ext/ext-all.js>
5.
Ext.data.Store.Ext.extend.addext-all.js:7<http://localhost/aic40/js/ext/ext-all.js>
6.
Ext.data.Store.Ext.extend.loadRecordsext-all.js:7<http://localhost/aic40/js/ext/ext-all.js>
7.
Ext.data.Store.Ext.extend.loadDataext-all.js:7<http://localhost/aic40/js/ext/ext-all.js>
8. onAddLayerGeoExt.js:101<http://localhost/aic40/js/geoext/GeoExt.js>
9.
OpenLayers.Events.OpenLayers.Class.triggerEventOpenLayers.js:573<http://localhost/aic40/js/openlayers/OpenLayers.js>
10.
OpenLayers.Map.OpenLayers.Class.addLayerOpenLayers.js:841<http://localhost/aic40/js/openlayers/OpenLayers.js>
11. aic.map.FeatureCollection.Ext.extend.init
FeatureCollection.js:98<http://localhost/aic40/js/aic/map/FeatureCollection.js>
12. aic.map.FeatureCollection.Ext.extend.constructor
FeatureCollection.js:81<http://localhost/aic40/js/aic/map/FeatureCollection.js>
13.
aic.MapApps.Ext.extend.initMapaicapp.js:413<http://localhost/aic40/js/aicapp.js>
14.
Ext.Ajax.request.successaicapp.js:157<http://localhost/aic40/js/aicapp.js>
15.
Ext.extend.handleResponseext-all.js:7<http://localhost/aic40/js/ext/ext-all.js>
16.
fext-base.js:7<http://localhost/aic40/js/ext/adapter/ext/ext-base.js>
17.
mext-base.js:7<http://localhost/aic40/js/ext/adapter/ext/ext-base.js>
18. (anonymous function)
I search and found that Node xnode-67 is folder node.
How I can fix it?
Thanh you.
--
Nguyễn Đình Toán
_______________________________________________
Dev mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/dev