Last active
April 15, 2016 17:20
-
-
Save jugalpatel803/fa33acba37056989306074e6b8693cdf to your computer and use it in GitHub Desktop.
Grouped layers w/ layers not reversed
This file contains 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 = [], secondFloorLayers = [], thirdFloorLayers = []; | |
array.forEach(this.operLayerInfos.getLayerInfoArray(), function(layerInfo) { | |
//get the original layer title and add it to the new sublayer title | |
layerInfo.layerObject.title = layerInfo.title; | |
if(layerInfo && layerInfo.title.substr(0, 5) === "First"){ | |
firstFloorLayers.push(layerInfo.layerObject); | |
this.map.removeLayer(layerInfo.layerObject); | |
} | |
if(layerInfo && layerInfo.title.substr(0, 5) === "Secon"){ | |
secondFloorLayers.push(layerInfo.layerObject); | |
this.map.removeLayer(layerInfo.layerObject); | |
} | |
if(layerInfo && layerInfo.title.substr(0, 5) === "Third"){ | |
thirdFloorLayers.push(layerInfo.layerObject); | |
this.map.removeLayer(layerInfo.layerObject); | |
} | |
}, this); | |
//firstFloorLayers.reverse(); | |
//secondFloorLayers.reverse(); | |
//thirdFloorLayers.reverse(); | |
this.operLayerInfos.addFeatureCollection(firstFloorLayers, "1st Floor"); | |
this.operLayerInfos.addFeatureCollection(secondFloorLayers, "2nd Floor"); | |
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, true); | |
})); | |
}; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment