It seems to be a pretty common problem. I finished my Weather App and it worked great on my local host. It doesn’t work on codepen. I checked answers to similar plots and tried the solutions, but they didn’t work in my case.
Can anyone take a look and give me some feedback, please?
This method, triggering location with the city, was recommended by the openweathermap.org
I also found it more precise and easier as the lat and lon would need to be rounded and it could lead to some issues with the geolocation. And as said, it worked great on my local host.
I tried http://ip-api.com/json and this one works. Still, changing the url to http didnt help.
yes, I also tried this one. But this API is very unreliable. I tested it with friends and it shows wrong location. sometimes hundreds kms away from the actual one…
Do you know, by any chance, any other reliable IP lookups, with secure connection for free?
The FCC API seems to return a default value of Shuzenji, JP most of the time no matter what GPS coordinates you provide. It will occasionally return the correct information, though.
I looked into other APIs, but found that they were even less reliable than the FCC one.
@RadekKosiada if you take a look to my js code you will see that after retrieving lat and lon using geolocation, I’m making an extra call to the google maps api just to retrieve the address that I observed openweather api not always report it right. This solution I found is a little tricky as google maps api format the json based on the country, so this [2] var address = location.results[2].formatted_address; in my js was the best solution i could find. changing 2 to other 0…9 number will give you diff info
@sorinr thank you for sharing this.
I took the liberty to try from a different angle.
I added submit form and user has to write his/her location themselves. The moment they submit their location, the weather in their town is displayed.
I will make some more styling tomorrow, but I claim this task to be officially delivered
It’s a bit different than in the user story, but in the end it gives even more freedom and you can check several locations and not only your own.
@sorinr That’s a great tip.
I added it and it works here http://bit.ly/RadWeatherApp but doesn’t on codepen.
But thanks so much. I learned so much it’s been fun working on this task.