Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sublayer visibility issue #604

Merged
merged 1 commit into from
Oct 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions viewer/js/gis/dijit/Identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,10 @@ define([
if (layerInfo.subLayerIds !== null) {
return false;
}
// only include sublayers that are currently visible
if (array.indexOf(ref.visibleLayers, layerInfo.id) < 0) {

if (this.isDefaultLayerVisibility(ref) && !this.checkVisibilityRecursive(ref, layerInfo.id)) {
return false;
} else if (array.indexOf(ref.visibleLayers, layerInfo.id) < 0) {
return false;
}
// only include sublayers that are within the current map scale
Expand Down Expand Up @@ -543,6 +545,39 @@ define([
return true;
},

/**
* recursively check all a layer's parent(s) layers for visibility
* this only needs to be done if the layers visibleLayers array is
* set to the default visibleLayers. After setVisibleLayers
* is called the first time group layers are NOT included.
* @param {esri/layers/DynamicMapServiceLayer} layer The layer reference
* @param {Integer} id The sublayer id to check for visibility
* @return {Boolean} Whether or not the sublayer is visible based on its parent(s) visibility
*/
checkVisibilityRecursive: function (layer, id) {
var info = layer.layerInfos[id];
if (layer.visibleLayers.indexOf(id) !== -1 &&
(info.parentLayerId === -1 || this.checkVisibilityRecursive(layer, info.parentLayerId))) {
return true;
}
return false;
},
/**
* check each defaultVisibility and if its not in the visibleLayers
* array, then the layer has non-default layer visibility
* @param {esri/layers/DynamicMapServiceLayer} layer The layer reference
* @return {Boolean} Whether or not we're operating with the default visibleLayers array or not
*/
isDefaultLayerVisibility: function (layer) {
for (var i = 0; i < layer.layerInfos.length; i++) {
var item = layer.layerInfos[i];
if (item.defaultVisibility && layer.visibleLayers.indexOf(item.id) === -1) {
return false;
}
}
return true;
},

getLayerName: function (layer) {
var name = null;
if (layer.layerInfo) {
Expand Down Expand Up @@ -603,4 +638,4 @@ define([
}, this);
}
});
});
});