Local Weather Project - API refreshing

Hi all,

I think I’ve finished the local weather project here : https://codepen.io/HackinoSelov/full/qodmbW/ (note that I did not focus on the design ;-))

However, it seems that the app sometimes (often?) shows the exemple provided by FCC in its instructions (i.e. the weather of Shuzenji, until I’ve refreshed the page… And then, it shows the weather of where I’m currently am…

So, since my app shows the correct localisation (one out of three times…), I don’t understand whether this is a problem with the API or my code…

Thanks for your advice.


Little up…

Another issue I noticed is the following : when my colleague tries the website, he get the exact location, but when I do, the site returns a location at least 150km from where I stand (and I was in the exact same room of my colleague).

So is it an issue with the API ? with the browser ? My code? the ISP ?



I used an IP address lookup to get the lat & long.
GeoLocation is not reliable because the user may say no to “share your location”.

Of course, but in this case, we had both shared our (same) location…

Might be the browser then. I don’t know.

Put an alert which will show you the lat and long values before the call to $.getJSON. I have noticed on my own computer and definitely on mobile device that if the lat and long values received back from the call to navigator.geolocation.getCurrentPosition will change every so slightly. I also know that the FCC weather API rounds to two decimal places. When dealing with geo coordinates, you want as much precision as possible to create consistent results. Two decimal places is enough to throw the location off quite a bit.