Sub-layer default visibility in Local Layer Widget

4182
3
Jump to solution
06-30-2015 02:55 PM
ScottKiley
Occasional Contributor II

Is there a way to set whether a sub-layer is turned on or off at application start-up through the Local Layer Widget? Robert Scheitlin​ answered a similar question about the ability to set definition queries in the JSON (Local Layer Widget ). The behavior I'm looking to control is similar, so I thought I would ask if it's possible.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Scott,

   This is now part of Version 1.6 of the Local Layer Widget (which of course now has a GUI for handling this).

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Scott,

  There is currently no configuration for this but almost anything can be done if you do some coding.

In the Widget.js file find the case "DYNAMIC" and add the following lines(5 thru 12):

if(layer.type.toUpperCase() === 'DYNAMIC'){
            if(layer.imageformat){
              var ip = new ImageParameters();
              ip.format = layer.imageformat;
              if(layer.hasOwnProperty('hidelayers')){
                ip.layerIds = layer.hidelayers.split();
                ip.layerOption = ImageParameters.LAYER_OPTION_HIDE;
              }
              if(layer.hasOwnProperty('showlayers')){
                ip.layerIds = layer.showlayers.split();
                ip.layerOption = ImageParameters.LAYER_OPTION_SHOW;
              }
              if(layer.hasOwnProperty('imagedpi')){
                ip.dpi = layer.imagedpi;
              }
              lOptions.imageParameters = ip;
            }

Then in the config_Local Layer Widget.json add either showlayers or hidelayers (showlayers will overwrite hidelayers if you mistakenly add both).

the json property would look like this:

"hidelayers": "0,68,69,79,80,81,82,83"

If you need more context here is a full layer example:

     {
        "type": "Dynamic",
        "name": "Parcels",
        "url": "http://someserver/arcgis/rest/services/someservice/MapServer",
        "opacity": 0.9,
        "visible": true,
        "imageformat": "png32",
        "imagedpi": 96,
        "disableclientcaching": true,
        "hidelayers": "0,68,69,79,80,81,82,83"
      }
RobertScheitlin__GISP
MVP Emeritus

Scott,

   This is now part of Version 1.6 of the Local Layer Widget (which of course now has a GUI for handling this).

ScottKiley
Occasional Contributor II

Robert Scheitlin Thanks for the prompt reply and the great help as always.

0 Kudos