Hi!!!
I have a problem with group layer on widget LayerList... disable visibility (checkbox) of the layers don't work, neither when I unckeck the group layer that contain the layers that I have disable visibility...
Somebody had this problem?? How can I resolve it???
Solved! Go to Solution.
Hi, people!
Problem resolved!
How I already had replaced the widget Beta 1 by Beta 2, I discovered that a array was being created wrong, including the indexs of groups. So I manipulated this array to remove all index of all groups before send to toggle the visibility.
This array is manipulated in ...\jimu.js\LayerInfos\LayerInfoForMapService.js, the method is "setSubLayerVisible". Follows the code of my solution:
// Gets the correspondent layer info
getLayerInfo: function(layerInfos, id) {
var layerInfo = null;
for (var i = 0; layerInfos.length; i++) {
if (layerInfos.id == id) {
layerInfo = layerInfos;
break;
}
}
return layerInfo;
},
// Removes all indexs of all groups
clearVisibleLayers: function(visibleLayers, layerInfos) {
var myVisibleLayers = lang.clone(visibleLayers);
var myLayerInfos = layerInfos;
var layerInfo = null;
array.forEach(visibleLayers, lang.hitch(this, function(idVisibleLayer){
layerInfo = this.getLayerInfo(myLayerInfos, idVisibleLayer)
if (layerInfo && layerInfo.subLayerIds != null) {
var index = array.indexOf(myVisibleLayers, idVisibleLayer);
myVisibleLayers.splice(index, 1);
}
}), this);
return myVisibleLayers;
},
setSubLayerVisible: function(subLayerId, visible) {
var ary = [],
index;
if (subLayerId !== null) {
// Here is the alteration
ary = lang.clone(this.originOperLayer.layerObject.visibleLayers);
ary = this.clearVisibleLayers(ary, this.originOperLayer.layerObject.layerInfos);
index = array.indexOf(ary, subLayerId);
if (visible) {
if (index < 0) {
ary.push(subLayerId);
this.originOperLayer.layerObject.setVisibleLayers(ary);
}
} else {
if (index >= 0) {
ary.splice(index, 1);
}
if (ary.length === 0) {
ary.push(-1);
}
this.originOperLayer.layerObject.setVisibleLayers(ary);
}
}
},
Erik,
are you talking about ArcGIS Desktop, Javascript API, Flex?
If it is a webapplication can you post some code?
Tim
The aplication was created by App Builder for Javascript... the widget is LayerList
Hello people!!
Some idea??
Erik,
I have not seen this behavior. Which version of the beta are you using?
Robert, tanks for your answer!
I created my application with AppBuilder Beta 1, but I have replaced only the LayerList widget from Beta 2 and anything changed.
What version are you using?
Erik,
I am using Beta 3. There is likely things that they changed in the StemApp from Beta 1 to Beta 2 that don't work with you just copying just the LayerListWidget from Beta 2 into Beta 1.
Do you think that if I copy the LayerListWidget from Beta 3 can works??
No, as I mentioned there was probably some core event or function changed in the StemApp that needs the widget and the StemApp to be on the same version. Mixing versions is not a recommended practice.
Understood!
So what's your recommendation for resolve this problem???