Mercurial > pub > ImplabJs
comparison src/djol/LayerSwitcher.js @ 34:27e8e9e38e07 default tip
Слияние
author | nickolay |
---|---|
date | Wed, 05 Jun 2019 20:44:15 +0300 |
parents | 8af8e840dd49 1dc2fd263b90 |
children |
comparison
equal
deleted
inserted
replaced
33:8af8e840dd49 | 34:27e8e9e38e07 |
---|---|
1 define([ | |
2 "dojo/_base/declare", | |
3 "require", | |
4 "dijit/_WidgetBase", | |
5 "dijit/_TemplatedMixin", | |
6 "dijit/_WidgetsInTemplateMixin", | |
7 "dojo/text!./resources/LayerSwitcherTemplate.html", | |
8 "./LayerCheckBox", | |
9 "./LayerRadioButton", | |
10 "app/view/Container" ], | |
11 | |
12 function(declare, require, _WidgetBase, _TemplatedMixin, | |
13 _WidgetsInTemplateMixin, templateString, LayerCheckBox, LayerRadioButton) { | |
14 | |
15 return declare([ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], { | |
16 templateString : templateString, | |
17 requireScope : require, | |
18 _layers : null, | |
19 _map : null, | |
20 | |
21 infoLayersLabel : "Layers", | |
22 _setInfoLayersLabelAttr : { | |
23 node : "infoLayersLabelNode", | |
24 type : "innerHTML" | |
25 }, | |
26 | |
27 baseLayersLabel : "Base", | |
28 _setBaseLayersLabelAttr : { | |
29 node : "baseLayersLabelNode", | |
30 type : "innerHTML" | |
31 }, | |
32 | |
33 constructor : function(options) { | |
34 options = options || {}; | |
35 | |
36 if (!options.map) | |
37 throw new Error("The map is required"); | |
38 | |
39 this._map = options.map; | |
40 | |
41 if (options.layers && options.layers instanceof Array) | |
42 this._layers = options.layers; | |
43 else | |
44 this._layers = []; | |
45 | |
46 // this.baseLayersLabel = "Base"; | |
47 | |
48 }, | |
49 | |
50 postCreate : function() { | |
51 this.inherited(arguments); | |
52 | |
53 var pending = []; | |
54 | |
55 for ( var i in this._layers) { | |
56 if (this._layers[i].get("layerType") != "base") | |
57 pending.push(this._layers[i]); | |
58 else | |
59 this._addLayer(this._layers[i]); | |
60 } | |
61 | |
62 for ( var i in pending) | |
63 this._addLayer(pending[i]); | |
64 }, | |
65 | |
66 _addLayer : function(layer) { | |
67 this._map.addLayer(layer); | |
68 | |
69 if (layer.get("layerType") === "base") { | |
70 this.baseLayersContainer.addChild(new LayerRadioButton({ | |
71 layer : layer | |
72 })); | |
73 } else { | |
74 this.infoLayersContainer.addChild(new LayerCheckBox({ | |
75 layer : layer | |
76 })); | |
77 } | |
78 }, | |
79 | |
80 }); | |
81 }); |