Hello,
I’m having some trouble using the getJSON() function in order to retrieve weather information for the weather application.
$(document).ready(function() {
$("#getWeather").click(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var url_api = "https://api.darksky.net/forecast/f8c931a74f233b551ed121edbb142777/"+lat+","+lon;
$.getJSON(url_api, function(json) {
$("ul").html("<li>latitude: " + json.latitude + "</li>");
console.log()
$("ul").html("<li>longitude: " + json.longitude + "</li>");
});
});
}
});
});
I’m trying to approach the problem piece-by-piece by just getting my application to show me the latitude and longitude before I proceed with getting the temperature, and weather.