From 5dacdd29d7bfa86301cb790655720dbd1e14053d Mon Sep 17 00:00:00 2001 From: Tim McGee Date: Fri, 6 Nov 2015 11:55:43 -0800 Subject: [PATCH] Added new `layerIds` option to layerControl configuration. This array determines which sublayer and folder controls are visible. The visibility of the actual sublayers is not affected. Also includes `layerIds` array in imageParameters to demonstrate how to set the initial visibility of sublayers. --- viewer/js/config/viewer.js | 8 +++++++- .../js/gis/dijit/LayerControl/controls/_DynamicFolder.js | 4 ++++ .../gis/dijit/LayerControl/controls/_DynamicSublayer.js | 4 ++++ viewer/js/gis/dijit/LayerControl/css/LayerControl.css | 7 +++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/viewer/js/config/viewer.js b/viewer/js/config/viewer.js index 8ed10af85..b22497e15 100644 --- a/viewer/js/config/viewer.js +++ b/viewer/js/config/viewer.js @@ -124,11 +124,17 @@ define([ id: 'louisvillePubSafety', opacity: 1.0, visible: true, - imageParameters: buildImageParameters() + imageParameters: buildImageParameters({ + layerIds: [0, 2, 4, 5, 8, 10, 12, 21], + layerOption: 'show' + }) }, identifyLayerInfos: { layerIds: [2, 4, 5, 8, 12, 21] }, + layerControlLayerInfos: { + layerIds: [0, 2, 4, 5, 8, 9, 10, 12, 21] + }, legendLayerInfos: { layerInfo: { hideLayers: [21] diff --git a/viewer/js/gis/dijit/LayerControl/controls/_DynamicFolder.js b/viewer/js/gis/dijit/LayerControl/controls/_DynamicFolder.js index 2631e34ba..8c949d037 100644 --- a/viewer/js/gis/dijit/LayerControl/controls/_DynamicFolder.js +++ b/viewer/js/gis/dijit/LayerControl/controls/_DynamicFolder.js @@ -35,6 +35,10 @@ define([ _expandClickHandler: null, postCreate: function () { this.inherited(arguments); + // Should the control be visible or hidden? + if (this.control.controlOptions.layerIds && this.control.controlOptions.layerIds.indexOf(this.sublayerInfo.id) < 0) { + domClass.add(this.domNode, 'layerControlHidden'); + } var checkNode = this.checkNode; domAttr.set(checkNode, 'data-sublayer-id', this.sublayerInfo.id); domClass.add(checkNode, this.control.layer.id + '-layerControlSublayerCheck'); diff --git a/viewer/js/gis/dijit/LayerControl/controls/_DynamicSublayer.js b/viewer/js/gis/dijit/LayerControl/controls/_DynamicSublayer.js index cbe35b987..2f545c073 100644 --- a/viewer/js/gis/dijit/LayerControl/controls/_DynamicSublayer.js +++ b/viewer/js/gis/dijit/LayerControl/controls/_DynamicSublayer.js @@ -45,6 +45,10 @@ define([ _expandClickHandler: null, postCreate: function () { this.inherited(arguments); + // Should the control be visible or hidden? + if (this.control.controlOptions.layerIds && this.control.controlOptions.layerIds.indexOf(this.sublayerInfo.id) < 0) { + domClass.add(this.domNode, 'layerControlHidden'); + } var checkNode = this.checkNode; domAttr.set(checkNode, 'data-sublayer-id', this.sublayerInfo.id); domClass.add(checkNode, this.control.layer.id + '-layerControlSublayerCheck'); diff --git a/viewer/js/gis/dijit/LayerControl/css/LayerControl.css b/viewer/js/gis/dijit/LayerControl/css/LayerControl.css index f805803da..2a09ad53e 100644 --- a/viewer/js/gis/dijit/LayerControl/css/LayerControl.css +++ b/viewer/js/gis/dijit/LayerControl/css/LayerControl.css @@ -67,6 +67,13 @@ text-align: center; } +.layerControlDijit .layerControlHidden { + display: none; +} +.layerControlDijit .layerControlVisible { + display: block; +} + .layerControlDijit .layerControlIndent { padding-left: 22px; }