我有一个天气小部件,我需要动态背景。雅虎有天气 API,但我无法找到与天气类型相关的背景图像。https://weather.yahoo.com/ https://weather.yahoo.com/这可能吗?
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不提供任何图像,但您可以使用大量数据自己提供图像。例如使用以下属性
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..
}, ...
等等。正如您所看到的,有很多方法可以说明这些数据,但这完全取决于您如何去做。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)