From 9a9a779e4a497da77b4d0ebff708bbdcac4a9ba4 Mon Sep 17 00:00:00 2001 From: Xaloc Date: Mon, 5 Apr 2021 22:02:14 +0200 Subject: [PATCH] add map cloud coverage --- index.html | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/index.html b/index.html index 2a4e1e2..3e9e599 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,12 @@ + +
@@ -19,6 +25,10 @@
+
+

Cloud Coverage Forcast for the next hour

+
+

Aurora Forecast

@@ -50,5 +60,39 @@ } window.onload = api; + + var mymap = L.map('mapid').setView([67.8488, 20.3027], 6); + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 19, + attribution: '© OpenStreetMap' + }).addTo(mymap); + var kiruna = L.marker([67.8488, 20.3027]).addTo(mymap); + kiruna.bindPopup("Kiruna"); + var abisko = L.marker([68.35, 18.8166]).addTo(mymap); + abisko.bindPopup("Abisko"); + + async function clouds(){ + const valTime = await fetch('https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/validtime.json'); + const times = await valTime.json(); + var time = times.validTime[1].replace(/-/g, "").replace(/:/g, ""); + document.getElementById('clouds').textContent = "Cloud Coverage Forcast for " + times.validTime[1].replace(/T/g, " ").replace(/Z/g, " UTC"); + const res = await fetch(`https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/multipoint/validtime/${time}/parameter/tcc_mean/leveltype/hl/level/0/data.json`); + const data = await res.json(); + + for(i=0; i