Skip to content

Instantly share code, notes, and snippets.

@jugalpatel803
Created April 11, 2016 19:04
Show Gist options
  • Select an option

  • Save jugalpatel803/3900ca08f89aece4f6e732b610fefe2d to your computer and use it in GitHub Desktop.

Select an option

Save jugalpatel803/3900ca08f89aece4f6e732b610fefe2d to your computer and use it in GitHub Desktop.
Grouped Layers in ArcGIS
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);
}));
}
},
@ezequias
Copy link

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment