真的很好的强大的jQuery的天气实施与用户位置的饲料

问题描述:

嘿,我搜遍了整个地方,不能真正打定了主意。我安装了一个天气小工具,可以避开雅虎服务器的天气,但我无法弄清楚如何做一些事情。自动从DAY切换到NIGHT图像,无需进行某种破解。我也不确定如何进行为期5天的预测。真的很好的强大的jQuery的天气实施与用户位置的饲料

这是我使用的是什么:

$.YQL = function(query, callback) { 
     var encodedQuery = encodeURIComponent(query.toLowerCase()), 
     url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodedQuery + '&format=json&callback=?'; 
     $.getJSON(url, callback); 
    }; 

    $.YQL("SELECT * FROM weather.forecast WHERE location = 93065", function(data){ 
     var w = data.query.results.channel; 

     var d = new Date(); 
     var curr_hour = d.getHours(); 
     var dn = (curr_hour < 18 && curr_hour > 4 ? 'd' : 'n'); 

     var weatherImage = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + dn + ".png"; 
     var weatherIcon = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + "s.png"; 
     $('.weatherImage').html("<img src='" + weatherImage + "' />"); 
     $('.weatherTemp').html(w.item.condition.temp + "&deg;"); 
     $('.weatherText').html(w.item.condition.text); 

     $(this).everyTime('300s', function(){ 
      var w = data.query.results.channel; 
      var d = new Date(); 
      var curr_hour = d.getHours(); 
      var dn = (curr_hour < 18 && curr_hour > 4 ? 'd' : 'n'); 

      var weatherImage = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + dn + ".png"; 
      var weatherIcon = "http://l.yimg.com/a/i/us/nws/weather/gr/" + w.item.condition.code + "s.png"; 
      $('.weatherImage').html("<img src='" + weatherImage + "' />"); 
      $('.weatherTemp').html(w.item.condition.temp + "&deg;"); 
      $('.weatherText').html(w.item.condition.text); 
     }); 
    }).appendTo('.pin-up-weather'); 

不漂亮,但它的一个短期的解决办法。有没有人有过相当动态的定制天气馈送的经验?

我想有只更新基于该用户从浏览天气,但我不知道这就是可能的。我看了谷歌地理定位API,但不再有服务,地图api接管的东西,但我仍然无法弄清楚。

如果不是我很好,与具有脚本取决于他们的个人资料是什么用户指定的数据库抢位置。

感谢

+0

要找到一个地方WOEID看到答案发布在:> http://*.com/questions/1822650/yahoo-weather-api-woeid-retrieval – Neil 2011-02-02 03:19:16

一个迟到的答案,但我对面的jQuery插件simpleWeather来了。

这似乎是直线前进。