如何从API获取Yahoo Weather Backgrounds? [英] How can I get Yahoo Weather Backgrounds from API?
本文介绍了如何从API获取Yahoo Weather Backgrounds?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个天气小部件,并且需要动态背景.雅虎有天气API,但是我找不到与天气类型相关的背景图片. https://weather.yahoo.com/这可能吗?
I have a weather widget, and I need dynamic backgrounds. Yahoo has weather APIs, but I'm not able to find the background image tied to a weather type. https://weather.yahoo.com/ Is this possible?
var url = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D%2248907%22&format=json'
$.getJSON(url, function (data) {
console.log(data)
})
推荐答案
API不提供任何图像,但是您可以使用大量数据自行提供图像.例如,使用以下属性
The API doesn't provide any images, but you can use a lot of the data to provide an image yourselves. Use for example the following properties
condition":{"code":"34", ... // here you can bind an image to the code
那你有一个风对象
wind":{
"chill":"55", // thermometer?
"direction":"0", // use an image or a canvas to draw an arrow dynamically
"speed":"0"
}, ...
和一个大气物体
"atmosphere":{
"humidity":"51", // some drops?
"pressure":"30.4", // textual..
"rising":"2",
"visibility":"10" // textual..
}, ...
以此类推.如您所见,有很多方法可以说明这些数据,但是如何操作完全取决于您.
And so on. As you can see there are many ways to illustrate these data but it's entirely up to you how to do it.
这篇关于如何从API获取Yahoo Weather Backgrounds?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文