can someone help me and tell me what i might be doing wrong? console.log(lon); dont seem to be consoling the longitude from geolocation so i can get the lat and lon to create the weather API URL.
var lat = “”;
var lon = “”;
var url = “”;
var obj = {};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
lat = position.coords.latitude;
lon = position.coords.longitude;
url = “http://api.openweathermap.org/data/2.5/weather?lat=” + lat + “&lon=” + lon + “&appid=0fa32334aae58f9d4a6887841ba00e3e&units=metric”;
console.log(lon);
$.ajax({
type: "POST",
url: url,
contentType: "application/json",
dataType: "jsonp",
data: JSON.stringify(obj),
success: function(response) {
var weatherType = response.weather[0].description;
var ico = response.weather[0].icon;
var temp = response.main.temp;
//console.log(weatherType);
//console.log(temp)
//console.log(response);
// will need to do the following url based on icon code from JSON data "http://api.openweathermap.org/img/w/" + ico + ".png"
//console.log(ico);
},
error: function(response) {
console.log("error");
}
});
});
}