diff --git a/index.html b/index.html index b557b68..73297fe 100644 --- a/index.html +++ b/index.html @@ -6,18 +6,13 @@ -
-

Today

DATEAncaster +

Today

DATE{{readableloc}}

{{weather.current.temp}}°C

@@ -57,9 +52,24 @@ var app = angular.module('mainPage', []); app.controller('body', function($scope, $http) { //Some sort of async function so location is got before the script called - $http.get("https://api.openweathermap.org/data/2.5/onecall?lat=" + lat + "&lon=" + lon + "&units=metric&appid=5292f0a17ecbe4b523fe0609ed2c556f").then(function (response) { - $scope.weather = response.data; + $scope.weather = 0 + // $scope.weather.current.temp = 1; + navigator.geolocation.getCurrentPosition((position) => { + $scope.loaddata(position.coords.latitude, position.coords.longitude) }); + $http.get("http://ipinfo.io").then(function (response) { // Easier way to grab location name via IP + $scope.readableloc = response.data.city + ', ' + response.data.region; + + }) + $scope.loaddata = function(lat, lon) { + $http.get("https://api.openweathermap.org/data/2.5/onecall?lat=" + lat + "&lon=" + lon + "&units=metric&appid=5292f0a17ecbe4b523fe0609ed2c556f").then(function (response) { + $scope.weather = response.data; + $scope.lat = lat; + $scope.lon = lon; + }) + } }); + + \ No newline at end of file