Fusion layers/legend: activate folder includes subfolder

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fusion layers/legend: activate folder includes subfolder

torrini
Hi list,

Quick question:
is it possible to configure the layers/legend-window in a way that it activates all sub-folders when activating a folder?


That would simplify so much more!
In a next step it would be great to identify the "master-folder" with another icon when a sub-folder/-layer is inactive.


MapGuide 3.0
Maestro 6.0
Fusion layouts

-torrini
Reply | Threaded
Open this post in threaded view
|

Re: Fusion layers/legend: activate folder includes subfolder

swimming123
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);

Reply | Threaded
Open this post in threaded view
|

Re: Fusion layers/legend: activate folder includes subfolder

torrini
Thanks a lot for the quick response!

Unfortunately I didn't get it to work.
First, there is a } missing in the end, before menu.add(toggle_on);, isn't it?!
Second, I'm getting the error menu is not defined. I changed it to Jx.Menu.add, but that results into Jx.Menu.add is not a function.

What's the mistake?
Reply | Threaded
Open this post in threaded view
|

Re: Fusion layers/legend: activate folder includes subfolder

farman
In reply to this post by swimming123
This Problem is still there. Anyone have a solution? if yes please guide me
too.
thanx



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
_______________________________________________
mapguide-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapguide-users