define([ "dojo/_base/declare", "dojo/on", "dijit/_WidgetBase", "dijit/_TemplatedMixin", "./../layerTreeBuilder", "dojo/text!./templates/LayerList.html" ], function (declare, on, _WidgetBase, _TemplatedMixin, LayerTreeBuilder, template) { return declare("app.widgets.LayerList", [_WidgetBase, _TemplatedMixin], { templateString: template, map: null, config: null, postCreate: function () { this.inherited(arguments); this._attachEventHandlers(); this.initTOC(this.config); }, _attachEventHandlers: function () { var self = this; this.own( ); }, initTOC: function(config) { var self = this; // Layers LayerTreeBuilder.initLayerTrees(this.map.tocLayerInfos, this.layerDiv); // Basemap radios var basemaps = config.basemaps; for (var i = 0; i < basemaps.length; i++) { var radioContainer = document.createElement("div"), radioLabel = document.createElement("label"), radio = document.createElement("input"); radio.setAttribute("type", "radio"); radio.setAttribute("name", "basemap"); radio.setAttribute("value", basemaps[i]); if (i === 0) radio.setAttribute("checked", "checked"); radioLabel.appendChild(radio); radioLabel.appendChild(document.createTextNode(basemaps[i])); radioContainer.appendChild(radioLabel); this.basemapDiv.appendChild(radioContainer); on(radio, "change", function (e) { if (this.checked) { self.selectMap(this.value); } }); } }, selectMap: function(value) { if(this.map._isBingMap) { if (value === "Street") this.map.veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_ROAD); else if (value === "Aerial") this.map.veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL); else this.map.veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL_WITH_LABELS); } else { if (value === "Street") map.setBasemap("streets"); else if (value === "Aerial") map.setBasemap("satellite"); else map.setBasemap("hybrid"); } } }); });