-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
80 lines (77 loc) · 2.65 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import('./pkg')
.then((wasm) => {
const latitude_field = document.getElementById("custom-lat");
const longitude_field = document.getElementById("custom-long");
const zoom_field = document.getElementById("zoominput");
var current_latitude = 0.0;
var current_longitude = 0.0;
var current_zoom = 0.95;
zoom_field.value = current_zoom;
latitude_field.value = current_latitude;
longitude_field.value = current_longitude;
const redraw = () => {
latitude_field.value = current_latitude;
longitude_field.value = current_longitude;
wasm.draw(current_longitude, current_latitude, current_zoom);
};
zoom_field.addEventListener('change', ()=> {
current_zoom = zoom_field.value;
redraw();
});
latitude_field.addEventListener('change', ()=> {
current_latitude = latitude_field.value;
redraw();
});
longitude_field.addEventListener('change', ()=> {
current_longitude = longitude_field.value;
redraw();
});
document.getElementById('button-me').addEventListener('click', () => {
navigator.geolocation.getCurrentPosition(pos =>{
console.log(pos);
current_latitude = pos.coords.latitude;
current_longitude = pos.coords.longitude;
redraw();
}, err=> {console.log("Error getting position")})
});
document.getElementById("button-santa").addEventListener('click', ()=>{
console.log("santa button");
current_latitude = 90.0;
current_longitude = 0.0;
redraw();
})
document.getElementById("button-cyprus").addEventListener('click', ()=>{
console.log("cyrpus button");
current_latitude = 35.12;
current_longitude = 33.42;
redraw();
})
document.getElementById("button-capehorn").addEventListener('click', ()=>{
console.log("cape horn button");
current_latitude = -55;
current_longitude = -67;
redraw();
})
document.getElementById("button-new-york").addEventListener('click', ()=>{
console.log("new-york button");
current_latitude = 40.71;
current_longitude = -74.00;
redraw();
})
document.getElementById("button-beijing").addEventListener('click', ()=>{
console.log("beijing button");
current_latitude = 39.90;
current_longitude = 116.39;
redraw();
})
document.getElementById("button-paris").addEventListener('click', ()=>{
console.log("paris button");
current_latitude = 48.85;
current_longitude = 2.34;
redraw();
})
redraw();
document.getElementById("loading-message").textContent="";
console.log("Module loaded in js");
})
.catch(console.error);