diff --git a/viewer/js/gis/dijit/Identify.js b/viewer/js/gis/dijit/Identify.js index 25f470db9..8fe8f4af0 100644 --- a/viewer/js/gis/dijit/Identify.js +++ b/viewer/js/gis/dijit/Identify.js @@ -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 @@ -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) { @@ -603,4 +638,4 @@ define([ }, this); } }); -}); \ No newline at end of file +}); diff --git a/viewer/js/viewer/_LayoutMixin.js b/viewer/js/viewer/_LayoutMixin.js index a17e0e91b..76179906b 100644 --- a/viewer/js/viewer/_LayoutMixin.js +++ b/viewer/js/viewer/_LayoutMixin.js @@ -188,9 +188,9 @@ define([ aspect.after(splitter, '_stopDrag', lang.hitch(this, '_splitterStopDrag', key)); } } - if (panes[key].open !== undefined) { - this.togglePane(key, panes[key].open); - } + } + if (panes[key].open !== undefined) { + this.togglePane(key, panes[key].open, true); } if (key !== 'center' && this.panes[key]._splitterWidget) { domClass.add(this.map.root.parentNode, 'pane' + key); @@ -213,20 +213,46 @@ define([ this.resizeLayout(); }, - togglePane: function (id, show) { + togglePane: function (id, show, suppressEvent) { if (!this.panes[id]) { return; } var domNode = this.panes[id].domNode; if (domNode) { - var disp = (show && typeof (show) === 'string') ? show : (domStyle.get(domNode, 'display') === 'none') ? 'block' : 'none'; - domStyle.set(domNode, 'display', disp); - if (this.panes[id]._splitterWidget) { // show/hide the splitter, if found - domStyle.set(this.panes[id]._splitterWidget.domNode, 'display', disp); + var oldDisp = domStyle.get(domNode, 'display'); + var newDisp; + + if (typeof(show) === 'string' && (show === 'none' || show === 'block')) { + // Set (CSS Display Property) + newDisp = show; + } else if (typeof(show) === 'boolean') { + // Set (boolean) + newDisp = (show) ? 'block' : 'none'; + } else if (show === undefined) { + // Toggle + newDisp = (oldDisp === 'none') ? 'block' : 'none'; + } else { + this.handleError({ + source: '_LayoutMixin', + error: 'Invalid type passed as "show" property of "togglePane" function : ' + typeof(show) + }); + return; } - this.positionSideBarToggle(id); - if (this.panes.outer) { - this.panes.outer.resize(); + show = (newDisp === 'block'); + + if (newDisp !== oldDisp) { + domStyle.set(domNode, 'display', newDisp); + if (this.panes[id]._splitterWidget) { // show/hide the splitter, if found + domStyle.set(this.panes[id]._splitterWidget.domNode, 'display', newDisp); + } + this.positionSideBarToggle(id); + if (this.panes.outer) { + this.panes.outer.resize(); + } + + if (!suppressEvent) { + topic.publish('viewer/onTogglePane', {pane: id, show: show}); + } } } },