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:
Solved! Go to Solution.
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
}
}
});
Rolando,
Is this question really for a vanilla JS API application? If so what do you mean by operational layers?
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.
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
}
}
});