app.service('WeatherService', function($http) {
var service = {};
service.getLocation = function() {
return $http.jsonp("http://ipinfo.io/json?callback=JSON_CALLBACK");
};
service.getCurrentWeather = function(city) {
var api = "http://api.openweathermap.org/data/2.5/weather?q=";
var units = "&units=metric";
var appid = "&APPID=061f24cf3cde2f60644a8240302983f2"
var callback = "&callback=JSON_CALLBACK";
return $http.jsonp(api + city + units + appid + callback);
};
return service;
});
Could someone provide an explanation of the functionality within this block of code? I'm unclear on the purpose of each variable. What does the getLocation function do? Does it define a function? Are all these variables combined to form a URL at the end, with the JSON retrieving data from the webpage being accessed?