Infrastructure Map Server Developer

Infrastructure Map Server Developer

Valued Contributor
88 Posts
1 Kudo
Registered: ‎04-12-2012
Post 1 of 3

Programmingly Turn ON/OFF BaseLayerGroup

580 Views, 2 Replies
03-21-2013 02:04 PM

In order to create a customed buttom to turn on/off BaseLayerGroup programmingly (instead of click the ckeckbox in the Legend), I use the following methods:

  • create an xml and js file, use invoke script method, here is the js file:

          Fusion.Widget.Image = OpenLayers.Class(Fusion.Widget,
               uiClass: Jx.Button,
           initializeWidget: function(widgetTag)
        activate: function(turn)
           //var theLegend = Fusion.getWidgetById("Legend");
           //var theMap = Fusion.getWidgetById("Map");        
           var currentGroup = document.getElementsByTagName("input");
                   var i = currentGroup.length - 1;  
                   alert(i);                        //it alert total input box 125;
                   alert(currentGroup[i]);        //it shows this is an HTML checkbox object
                   alert(currentGroup[i].checked);        //it alert this checkbox is not checked, false
                   currentGroup[i].checked = !(currentGroup[i].checked); 
                   alert(currentGroup[i].checked);      //it shows this checkbox is now checked, true
            } );
although above alert information shows my function is working, but I check the "Legend", the final checkbox state not change, still unchecked;

  • use the server side code to turn the group on

                String sessionId = Request.QueryString.Get("session");
                String mapName = Request.QueryString.Get("MapName");

                Utility utility = new Utility();
                MgSiteConnection siteConnection = utility.GetSiteConnection();
                if (siteConnection == null)
                    Response.Write("fail to get site connection, exit");
                MgResourceService resSvc =              (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
                MgMap map = new MgMap();
                map.Open(resSvc, mapName);
                double scale = map.GetViewScale();
                if (scale <= 18000)
                     MgLayerGroup layerGroup = utility.getGroupByName(map, "OrthoImage");
                     layerGroup.LegendLabel = "Ortho Image";
                     string refreshMap = "<script type='text/javascript'>RefreshMap()</script>";
                     Page.ClientScript.RegisterStartupScript(this.GetType(), "", refreshMap);
                     if (layer.IsVisible() == true)
                         Response.Write("<br/>&nbsp Artho Photo Image Added.");
                         Response.Write("<br/>&nbsp Artho Photo Image Removed.");



when the button clicked, above code also shows a message "Artho Photo Image Added." But the reality is not turned on.


Any suggestion for this solution is appreciated.



Active Member
9 Posts
0 Kudos
Registered: ‎08-29-2005
Post 2 of 3

Re: Programmingly Turn ON/OFF BaseLayerGroup

09-06-2013 09:58 AM in reply to: swimming123



This post explains how to do that:


Hope this helps.



Valued Contributor
88 Posts
1 Kudo
Registered: ‎04-12-2012
Post 3 of 3

Re: Programmingly Turn ON/OFF BaseLayerGroup

09-06-2013 12:41 PM in reply to: francisco.rojas

It's not helpful due to the group is BaseLayerGroup. I made it work by changing the FusionSF.js, then compress it and replace the original one.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post