Need help with Weather Project

Need help with Weather Project
0.0 0

#1

Okay, I have a couple problems I’m burnt out on and need some guidance.
I struggled with the open weather API, tried EVERYTHING, and ended up having to use Darksky.net, and it only worked when i used cors-anywhere.herokuapp.com in front of the url.

My main problem is I have no idea how to get/use the skycons that darksky uses. Here’s the instructions and I have no idea what to do with them. http://darkskyapp.github.io/skycons/.

I decided to try and just change the background based on what comes up on the span id “weather” which is the first element in my container div. However I have no idea how/where to start, Ive been searching for examples online and I’m still clueless. Here is my project so far: http://codepen.io/711levi711/pen/egggbz

Thank you so much for your help!


#2

So It looks like you are already popoulating the DOM with the weather data you’re getting from your API. That’s a great start. Regarding your background image I dont want to give you an answer but maybe guide your thinking a bit.

We’ve confirmed you know how to get a value from your API, say “foggy” for example. Now based on this value, we need to set a specific image. It looks like you’re using jQuery —Is there a jQuery function you can use to modify the css of elements?


#3

One posibitilty istead of stick with skycons that darksky uses, is to use another source of icons. i used this one. https://icons8.com/.

So think as, your api will return you a value for each posible icon, so just make a if / switch

if value X ---- use X image from another source


#4

I found skycons incredibly difficult to figure out! The code you need is actually all on that page. You just need to link to the github js page provided in the link and then assign the icon data you receive to the code for the skycons (I used a switch statement). Sounds easy now as I write it but also took me forever. Good luck! :wink: