aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/WeatherCurrent.svelte10
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) {