-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayers_ui.js
50 lines (39 loc) · 1.11 KB
/
layers_ui.js
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
40
41
42
43
44
45
46
47
48
49
50
// layers_ui.js
// Martin Pravda
/*jslint browser */
import make_ui from "./ui.js";
import dom from "./dom.js";
import layer_ui from "./layer_ui.js";
const layers_ui = make_ui("layers-ui", function (element, {
layers = [],
map
}) {
// let layer_controls;
let layer_switcher;
const shadow = element.attachShadow({mode: "closed"});
function add_layer({
ol_layer,
source
}) {
let layer_item;
const layer = layer_ui({
is_checked: true,
on_layer_removed: function () {
map.removeLayer(ol_layer);
layer_item.remove();
},
on_properties_clicked: function () {},
on_visibility_checked: function (checked) {
ol_layer.setVisible(checked);
},
title: source.name
});
layer_item = dom("li", [layer]);
layer_switcher.append(layer_item);
}
layer_switcher = dom("ul");
layers.forEach(add_layer);
shadow.append(layer_switcher);
element.add_layer = add_layer;
});
export default Object.freeze(layers_ui);