-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
54 lines (38 loc) · 1.03 KB
/
sketch.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
// Satellite records
let satrec;
// Position and velocity at specified time
let positionAndVelocity;
// TLE url
let TLEurl;
let iss;
let tleData;
let mymap;
let time;
function preload() {
let tleURL = 'https://api.wheretheiss.at/v1/satellites/25544/tles';
tleData = loadJSON(tleURL);
}
function setup() {
iss = new ISS(satellite, tleData, jspredict);
time = millis();
mymap = L.map('mapid').setView([51.505, -0.09], 2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);
updateCurrentPosition(mymap);
}
function draw() {
if (millis() > time + 500) {
iss.update(mymap);
time = millis();
}
}
function updateCurrentPosition(map) {
if (!navigator.geolocation){
console.log("Not supported");
return;
}
navigator.geolocation.getCurrentPosition(function(position) {
iss.setCurrentPosition(position.coords.latitude, position.coords.longitude, map);
});
}