forked from reearth/plugin-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiss.js
More file actions
71 lines (62 loc) · 1.74 KB
/
Copy pathiss.js
File metadata and controls
71 lines (62 loc) · 1.74 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
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
const html = `
<style>
body { margin: 0; }
.extendedh { width: 100%; }
.extendedv { height: 100%; }
#wrapper {
border: 2px solid blue;
border-radius: 5px;
background-color: rgba(111, 111, 111, 0.5);
box-sizing: border-box;
width: 300px;
}
.extendedh body, .extendedh #wrapper { width: 100%; }
.extendedv body, .extendedv #wrapper { height: 100%; }
</style>
<div id="wrapper">
<h1>Current ISS location</h1>
<p>Latitude: <span id="lat">-</span></p>
<p>Longitude: <span id="lon">-</span></p>
<p>Altitude: <span id="alt">-</span>km</p>
<p>
<button id="update">Update</button>
<button id="jump">Jump</button>
</p>
</div>
<script>
let lat, lng, alt;
const update = () => {
// WORKSHOP: HERE IS CODE TO FETCH ISS DATA
};
const send = () => {
// WORKSHOP: HERE IS CODE TO SEND DATA TO RE:EARTH
};
document.getElementById("update").addEventListener("click", update);
document.getElementById("jump").addEventListener("click", send);
const updateExtended = e => {
if (e && e.horizontally) {
document.documentElement.classList.add("extendedh");
} else {
document.documentElement.classList.remove("extendedh");
}
if (e && e.vertically) {
document.documentElement.classList.add("extendedv");
} else {
document.documentElement.classList.remove("extendedv");
}
};
addEventListener("message", e => {
if (e.source !== parent || !e.data.extended) return;
updateExtended(e.data.extended);
});
updateExtended(${JSON.stringify(reearth.widget.extended || null)});
update();
</script>
`;
reearth.ui.show(html);
reearth.on("update", () => {
reearth.ui.postMessage({
extended: reearth.widget.extended
});
});
// WORKSHOP: HERE IS CODE TO MOVE CAMERA