I used the data resource of OpenWeatherMap to call 16 day / daily forecast data, in which the “q=Beijing” can be changed to any city.
This is the final sketch(click submit):
In this sketch, the curve graph shows the variation tendency of next 16 days’ evening temperatures basing on today’s evening temperature.
And if it has a rainy day in the next 16 days, there will be rain drops in the background. But there are some problems with the conditional expression of the code.
//I finally solved the problem: instead of using “weather.list.weather.main”, I should use weather.list.weather.main. Because by using “console.log(weather.list[i].weather.main);” , there is no data coming in. So I came back to the JASON data, I found that the weather is also an array, which only has one element in it. It’s kind of weird.
The code can be seen here.
In the future, I can complete this sketch to make it more like a beautiful weather APP.
October 27, 2016 , 2:18 pm
Leave a comment