Hello!
I wonder if anyone can help:
In my show the local weather code the response from the API request to fcc-weather-api.glitch.me shows the weather for Shuzenji, Japan. This is a bit weird as my location is Sweden!
My code works like this:
In the $(document).ready(function() {
I check if the navigator.geolocation functionality is on and if so I call the function:
navigator.geolocation.getCurrentPosition(success, error);
In the success callback function I set the retrieved latitude and longitude values to 2 variables.
I use these variables to render a Google Map. This bit works great, and I get a map showing my correct location in Sweden- so everybody happy so far.
_ var img = new Image();_
_ img.src = googleMapsAPIURL + sLatitude + “,” + sLongitude + “&zoom=13&size=300x300&sensor=false”;_
_ output.appendChild(img);_
Here I also set a global var weather_url with the retrieved latitude and longitude values:
weather_url = “https://fcc-weather-api.glitch.me/api/current?lat=&"+sLatitude+"&lon=”+sLongitude;
From within this success function I call another function that does the getJSON Get API request using the weather_url variable.
It is here that I get back an API response containing weather data for Shuzenji, Japan, and not my location in Sweden.
I have even checked the outgoing url from within the function that does the getJSON API call and can see that the supplied latitude and longitude variable values are correct for my location.
I am stumped as to what can be causing this. Any ideas/help would be fantastic as I have been stuck on this and trying different ways to solve this for a few days now.
Note, at the time of writing this post it seems the weather API is unreachable (I am getting a 504 gateway timeout response). Maybe it’s the API itself, but if anyone else has had similar issues it would be great to hear from you.
Thanks in advance