How can I get the sublayers visible of thematic layer?

1133
3
Jump to solution
02-01-2017 11:03 AM
RolandoFlorez
New Contributor III

I want to get the information about sublayer visible, but, from operational layers (this.map.getLayersVisibleAtScale())
In widget legend, this information is getting from layerInfos class, but, Is there any propertie like this with the operational layers?

I want something like this:

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Rolando,

   Since you mention jimu that means you are talking about WAB. You really need to post your questions in the appropriate space Web AppBuilder for ArcGIS‌. Though WAB uses the JS API there are many classes and libraries that are specific to WAB and thus questions need to asked in that space.

Yes the jimu.js LayerInfos class should suit your needs just fine.

          var layerInfosObject = LayerInfos.getInstanceSync();
          var li = layerInfosObject.getLayerInfoById(layer.id);

          array.map(li.newSubLayers, function(lyr, indx){
            if(Boolean(li.subLayerVisible[indx])){
              if(lyr.isInScale()){
                //do something because the sublayer is in scale
              }
            }
          });

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Rolando,

   Is this question really for a vanilla JS API application? If so what do you mean by operational layers?

0 Kudos
RolandoFlorez
New Contributor III

Robert, if you print the map object in console, you can find it:
Map> ItemInfo > ItemData > operationalLayer > array (depending).
That is that I mean.

This layers has not subLayerVisible attribute like image above, this layers has this attribute instead:

I want to make a widget like legend widget, that it's listening when a layer is not visible at a current scale. I thought that LayerInfos class (in jimu.js) would help me here, but no. LayerInfos object only listen when I disabled a layer from LayerList widget.
I hope you can understand me.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Rolando,

   Since you mention jimu that means you are talking about WAB. You really need to post your questions in the appropriate space Web AppBuilder for ArcGIS‌. Though WAB uses the JS API there are many classes and libraries that are specific to WAB and thus questions need to asked in that space.

Yes the jimu.js LayerInfos class should suit your needs just fine.

          var layerInfosObject = LayerInfos.getInstanceSync();
          var li = layerInfosObject.getLayerInfoById(layer.id);

          array.map(li.newSubLayers, function(lyr, indx){
            if(Boolean(li.subLayerVisible[indx])){
              if(lyr.isInScale()){
                //do something because the sublayer is in scale
              }
            }
          });
0 Kudos