-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.js
35 lines (28 loc) · 1.02 KB
/
weather.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
var x = document.getElementById("demo");
var lat,long;
var url;
var weather;
function getLocation(button1) {
if (navigator.geolocation) {
document.getElementById('mainButton').style.visibility = 'hidden';
document.getElementById('lander').innerHTML = "Loading..."
navigator.geolocation.getCurrentPosition(callLocation);
setTimeout(() => {button1.onClick = generatePlayList(weather) }, 10000);;}
else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function callLocation(position){
lat = Math.round(position.coords.latitude * 100) / 100;
long = Math.round(position.coords.longitude * 100) / 100;
console.log(lat);
console.log(long);
url = "https://seven-timer-https-proxy.herokuapp.com?lon=" + long.toString() + "&lat=" + lat.toString() + "&product=civil&output=json"
fetch(url)
.then(res => res.json())
.then((out) => {
console.log(out.dataseries[2]);
weather = out.dataseries[2];
})
.catch(err => console.error(err));
}