-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (26 loc) · 1.14 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
app = angular.module('todoApp', []);
app.controller('WeatherController',function ($scope, $http) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
var lat = position.coords.latitude;
var long = position.coords.longitude;
var url = "https://api.darksky.net/forecast/df486ca05c0483463a08a1b4b445d9af/"+lat+","+long;
$http.get(url).then(function (res) {
console.log(res.data);
var temp = res.data.currently.apparentTemperature;
var resumen = res.data.currently.summary;
var icon = res.data.currently.icon;
//t (ºC)= t (ºF) – 32 / 1,8
var celcius = (temp - 32)/1.8;
$scope.resumen = resumen;
$scope.temperatura = temp;
$scope.celcius = Math.round(celcius);
var skycons = new Skycons({"color": "black"});
skycons.add("icon1", icon);
skycons.play();
});
});
} else {
alert( "Geolocation is not supported by this browser.");
}
});