-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_ui.js
62 lines (51 loc) · 1.24 KB
/
map_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
51
52
53
54
55
56
57
58
59
60
61
62
// map_ui.js
// Martin Pravda
/*jslint */
import Map from "ol/Map.js";
import View from "ol/View.js";
import {defaults} from "ol/control/defaults.js";
import make_ui from "./ui.js";
import dom from "./dom.js";
const map_ui = make_ui("map-ui", function (element) {
const ol_map = new Map({
controls: defaults({
attribution: false,
attributionOptions: false,
rotate: false,
rotateOptions: false,
zoom: false,
zoomOptions: false
}),
view: new View({
center: [0, 0],
zoom: 2
})
});
const shadow = element.attachShadow({mode: "closed"});
const map_root = dom("div", {
style: {
height: "500px",
position: "relative",
width: "100%"
}
});
function get_map() {
return ol_map;
}
function dispose_map() {
ol_map.dispose();
}
element.get_map = get_map;
shadow.append(map_root);
return {
connect() {
ol_map.setTarget(map_root);
},
disconnect() {
dispose_map();
}
};
});
//demo import demo from "./demo.js";
//demo demo(map_ui());
export default Object.freeze(map_ui);