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 | |
parent | 5022e2a2725aab5ac3d3925155295e2e7ecbcaa4 (diff) | |
download | Aurora-data-4a5ada21c5048ea0c1adfb0625b6340f58e6e25f.tar.gz Aurora-data-4a5ada21c5048ea0c1adfb0625b6340f58e6e25f.zip |
Add pulling of location
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/components/WeatherCurrent.svelte | 10 | ||||
-rw-r--r-- | static/manifest.json | 2 |
3 files changed, 12 insertions, 3 deletions
@@ -5,4 +5,5 @@ hunting for northern lights. In a Progressive web app, which polls all API's dir # Credits - All data related to space weather is from [USA National Space Weather Prediction Center](https://www.swpc.noaa.gov). - All weather data is from [MET Norway](https://met.no). -- Background photo by [Jonatan Pie](https://unsplash.com/@r3dmax?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/northern-lights?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) +- Background photo by [Jonatan Pie](https://unsplash.com/@r3dmax?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/northern-lights?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText). +- Location name is pulled from [geocode](https://geocode.xyz/api). 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) { diff --git a/static/manifest.json b/static/manifest.json index d2499f0..a4026e3 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -2,7 +2,7 @@ "background_color": "#464a47", "theme_color": "#5ac775", "name": "Aurora Data", - "short_name": "aurora data", + "short_name": "Aurora Data", "display": "fullscreen", "start_url": "/Aurora-data/", "orientation": "portrait", |