[fusion-users] Re: legend.js layer-group show
Jorge Soria
megajor at gmail.com
Thu Feb 3 03:03:51 EST 2011
Thanks for your help Paul.
I'm working with Mapguide OS 2.1.
The default behaviour is that clicking in a folder you show/hide that folder
(remembering the previous state of that group layers).
What I'm trying to do is that if you click in a folder show/hide the folder
and enable/disable all the layers from that group.
Working with legend.js:
What I do is to intercept the stateChanged event from the folder
stateChanged: function(obj, event) {
if (obj.legend && (obj.legend.treeItem instanceof Jx.TreeFolder))
{
if (obj.legend && obj.legend.treeItem.checkBox) {
if (obj.legend.treeItem.checkBox.checked) {
this.checkTree(obj.legend.treeItem);
} else {
this.uncheckTree(obj.legend.treeItem);
}
}
}
if (obj.legend && obj.legend.treeItem.checkBox) {
if (obj.legend.treeItem.checkBox.checked) {
obj.show();
} else {
obj.hide();
}
}
OpenLayers.Event.stop(event, true);
},
//being:
checkTree: function(folder) {
var mapWidget = this.getMap();
for (var i=0; i<folder.nodes.length; i++) {
var item = folder.nodes[i];
var layer = mapWidget.aMaps[0].getLayerByName(item.getName());
layer.show();
sleep(200);
}
mapWidget.redraw();
},
uncheckTree: function(folder) {
var mapWidget = this.getMap();
for (var i=0; i<folder.nodes.length; i++) {
var item = folder.nodes[i];
var layer = mapWidget.aMaps[0].getLayerByName(item.getName());
layer.hide();
sleep(200);
}
mapWidget.redraw();
},
This is the way I get better results, but it still has problems activating
folders with a big number of layers.
Sometimes works correctly, but sometimes there are some layers that doesn´t
show or hide when the folder is clicked.
Thanks for your time, Jorge
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/legend-js-layer-group-show-tp5961859p5987889.html
Sent from the Fusion Users mailing list archive at Nabble.com.
More information about the fusion-users
mailing list