diff options
author | Jakob Stendahl <jakobste@uio.no> | 2020-10-14 14:00:36 +0200 |
---|---|---|
committer | Jakob Stendahl <jakobste@uio.no> | 2020-10-14 14:00:36 +0200 |
commit | 4a5ada21c5048ea0c1adfb0625b6340f58e6e25f (patch) | |
tree | 0b7ae41fe71ab9f309bcbe47ff9fcefb990cbe6f /src/components | |
parent | 5022e2a2725aab5ac3d3925155295e2e7ecbcaa4 (diff) | |
download | Aurora-data-4a5ada21c5048ea0c1adfb0625b6340f58e6e25f.tar.gz Aurora-data-4a5ada21c5048ea0c1adfb0625b6340f58e6e25f.zip |
Add pulling of location
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/WeatherCurrent.svelte | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/components/WeatherCurrent.svelte b/src/components/WeatherCurrent.svelte index c5cac3e..7ca6ac4 100644 --- a/src/components/WeatherCurrent.svelte +++ b/src/components/WeatherCurrent.svelte @@ -10,7 +10,7 @@ let locationSupported; let dataLoading = true; - let location = "The earth"; + let location = "-"; let date = "-"; let kp_now = "-"; let kp_min = "-"; @@ -25,6 +25,13 @@ temp = yr_data["properties"]["timeseries"][0]["data"]["instant"]["details"]["air_temperature"]; } + async function getLocation(longitude, latitude) { + console.log(`https://geocode.xyz/${longitude},${latitude}?geoit=json`); + let locDat = await fetch(`https://geocode.xyz/${latitude},${longitude}?geoit=json`).then(r => r.json()); + console.log(locDat); + location = locDat["city"]; + } + async function getUSNOAAData() { bz = (await fetch("https://services.swpc.noaa.gov/products/summary/solar-wind-mag-field.json").then(res => res.json()))["Bz"]; let kp_data = (await fetch('https://services.swpc.noaa.gov/products/noaa-planetary-k-index-forecast.json').then(res => res.json())); @@ -71,6 +78,7 @@ longitude = position.coords.longitude latitude = position.coords.latitude getMETNorData(longitude, latitude) + getLocation(longitude, latitude); } function locationError(err) { |