-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbottom_pane_ui.js
41 lines (31 loc) · 897 Bytes
/
bottom_pane_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
// bottom_pane.js
// Martin Pravda
// Bottom panel for coordinats and scale
/*jslint */
import make_ui from "./ui.js";
import make_coordinates from "./coordinates.js";
const make_bottom_pane = make_ui("map-bottom-pane", function (element, {
map
}) {
const shadow = element.attachShadow({mode: "closed"});
const view = map.getView();
const [x, y] = view.getCenter();
const coords_ui = make_coordinates({
coords: {x, y},
on_coords_update(x, y) {
view.setCenter([x, y]);
}
});
function update_coords(event) {
const [x, y] = event.coordinate;
coords_ui.update_coordinates(x, y);
}
map.on("pointermove", update_coords);
shadow.append(coords_ui);
return {
disconnect() {
map.un("pointermove", update_coords);
}
}
});
export default Object.freeze(make_bottom_pane);