Created
April 11, 2016 19:04
-
-
Save jugalpatel803/3900ca08f89aece4f6e732b610fefe2d to your computer and use it in GitHub Desktop.
Grouped Layers in ArcGIS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| startup: function() { | |
| this.inherited(arguments); | |
| NlsStrings.value = this.nls; | |
| // summary: | |
| // this function will be called when widget is started. | |
| // description: | |
| // according to webmap or basemap to create LayerInfos instance | |
| // and initialize operLayerInfos; | |
| // show layers list; | |
| // bind events for layerLis; | |
| if (this.map.itemId) { | |
| LayerInfos.getInstance(this.map, this.map.itemInfo) | |
| .then(lang.hitch(this, function(operLayerInfos) { | |
| this.operLayerInfos = operLayerInfos; | |
| //begin grouping feature layers for rooms and labels | |
| var firstFloorLayers = []; | |
| array.forEach(this.operLayerInfos.getLayerInfoArray(), function(layerInfo) { | |
| //this is where I am searching for specific layers using their title | |
| if(layerInfo && layerInfo.title.substr(0, 5) === "First"){ | |
| firstFloorLayers.push(layerInfo.layerObject); | |
| this.map.removeLayer(layerInfo.layerObject); | |
| } | |
| }, this); | |
| this.operLayerInfos.addFeatureCollection(firstFloorLayers, "1st Floor"); | |
| console.log("firstFloorLayers"); | |
| var secondFloorLayers = []; | |
| array.forEach(this.operLayerInfos.getLayerInfoArray(), function(layerInfo) { | |
| //this is where I am searching for specific layers using their title | |
| if(layerInfo && layerInfo.title.substr(0, 5) === "Secon"){ | |
| secondFloorLayers.push(layerInfo.layerObject); | |
| this.map.removeLayer(layerInfo.layerObject); | |
| } | |
| }, this); | |
| this.operLayerInfos.addFeatureCollection(secondFloorLayers, "2nd Floor"); | |
| var thirdFloorLayers = []; | |
| array.forEach(this.operLayerInfos.getLayerInfoArray(), function(layerInfo) { | |
| //this is where I am searching for specific layers using their title | |
| if(layerInfo && layerInfo.title.substr(0, 5) === "Third"){ | |
| thirdFloorLayers.push(layerInfo.layerObject); | |
| this.map.removeLayer(layerInfo.layerObject); | |
| } | |
| }, this); | |
| this.operLayerInfos.addFeatureCollection(thirdFloorLayers, "3rd Floor"); | |
| // end of code to group layers | |
| this.showLayers(); | |
| this.bindEvents(); | |
| dom.setSelectable(this.layersSection, false); | |
| })); | |
| } else { | |
| var itemInfo = this._obtainMapLayers(); | |
| LayerInfos.getInstance(this.map, itemInfo) | |
| .then(lang.hitch(this, function(operLayerInfos) { | |
| this.operLayerInfos = operLayerInfos; | |
| this.showLayers(); | |
| this.bindEvents(); | |
| dom.setSelectable(this.layersSection, false); | |
| })); | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you any code that makes it easy to search an specific item within a layers list (TOC)?
Have you any code that makes it easy to select a specific item or items on a layers list (TOC)?