For this task, the only useful pieces of information about each layer are:
- Is the subLayer visible
- Is subLayer within scale range
var identifyLayerIds = dojo.filter(map.layerInfos, function(layerInfo){
var mapScale = esri.geometry.getScale(map);
var layer = map.getLayer(layerInfo.id);
return (layer.visible && isWithinScaleRange(layerInfo,mapScale);
}).map(function(visibleLayerInfo){
return visibleLayerInfo.id;
});
function isWithinScaleRange(layerInfo, mapScale){
var isWithinScaleRange = true;
if ((layerInfo.minScale === 0) && (layerInfo.maxScale !== 0)) {
isWithinScaleRange = (mapScale > layerInfo.maxScale);
} else {
if ((layerInfo.maxScale === 0) && (layerInfo.minScale !== 0)) {
isWithinScaleRange = (mapScale < layerInfo.minScale);
} else {
if ((layerInfo.maxScale !== 0) && (layerInfo.minScale !== 0)) {
isWithinScaleRange = (mapScale < layerInfo.minScale) && (mapScale > layerInfo.maxScale);
}
}
}
return isWithinScaleRange;
}