[mapguide-users] Fusion layers/legend: activate folder includes subfolder

swimming123 allen.song at altusgroup.com
Fri Oct 9 09:40:04 PDT 2015


good question. we implement a customized tool which is toogle on/off a
folder(right click, turn all layers in sub folder on/off), the thing is
MapGuide javascript need to re-organized its structure and remove all global
name spaces. Here is a simple js code added to your single js file can make
it work, in this render function of this class
Fusion.Widget.Legend.TreeFolder add following:

        var self = this;
        if (self.options.image == null) {
            var toggle_on = new Jx.Menu.Item({
                label: 'Toggle all on',
                onClick: function () {
                    var current_scale = self.options.data.oMap.getScale();

                    for (var i = 0; i < self.options.data.layers.length;
++i) {
                        var layer = self.options.data.layers[i];

                        if (layer.maxScale > current_scale && layer.minScale
< current_scale) {
                            layer.show();
                        }
                    }

                    for (var i = 0; i < self.options.data.groups.length;
++i) {
                        var sub_group = self.options.data.groups[i];
                        
                        for (var j = 0; j < sub_group.layers.length; ++j) {
                            var layer = sub_group.layers[j];
                            if (layer.maxScale > current_scale &&
layer.minScale < current_scale) {
                                layer.show();
                            }
                        }
                        
                        sub_group.show();
                    }

                    self.options.data.show();
                    //map.zoomIn();
                }
            });
            var toggle_off = new Jx.Menu.Item({
                label: 'Toggle all off',
                onClick: function () {
                    var current_scale = self.options.data.oMap.getScale();

                    for (var i = 0; i < self.options.data.layers.length;
++i) {
                        var layer = self.options.data.layers[i];

                        if (layer.maxScale > current_scale && layer.minScale
< current_scale) {
                            layer.hide();
                        }
                    }

                    for (var i = 0; i < self.options.data.groups.length;
++i) {
                        var sub_group = self.options.data.groups[i];
                        
                        for (var j = 0; j < sub_group.layers.length; ++j) {
                            var layer = sub_group.layers[j];
                            if (layer.maxScale > current_scale &&
layer.minScale < current_scale) {
                                layer.hide();
                            }
                        }
                        
                        sub_group.hide();
                    }

                    self.options.data.hide();
                }
            });

            menu.add(toggle_on);
            menu.add(toggle_off);





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Fusion-layers-legend-activate-folder-includes-subfolder-tp5228979p5229044.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list