-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathLayerToggle.js
More file actions
39 lines (36 loc) · 1.03 KB
/
LayerToggle.js
File metadata and controls
39 lines (36 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dojo/topic',
'dojo/_base/array',
'dojo/_base/lang'
], function (
declare,
_WidgetBase,
topic,
array,
lang
) {
return declare([_WidgetBase], {
map: true,
// array of IDs for layers that can be toggled
layerGroup: [],
// ID of labels layer (if any)
labelsID: null,
postCreate: function () {
this.inherited(arguments);
topic.subscribe('layerControl/layerToggle', lang.hitch(this, function (r) {
if (array.indexOf(this.layerGroup, r.id) >= 0) {
array.forEach(this.layerGroup, lang.hitch(this, function (id) {
if (id !== r.id) {
var lyr = this.map.getLayer(id);
if (lyr) {
lyr.setVisibility(false);
}
}
}));
}
}));
}
});
});