2016-01-21 3 views
2

Я использую плагин simpleweather для отображения текущей погоды и работал до вчерашнего дня. Теперь он показывает ошибку как «не может прочитать канал свойства« null ». Когда я отлаживал скрипт, я обнаружил, что данные yahoo не могут получить сообщение о недоступности сервиса, поэтому query.results.channel имеет значение null. Может ли кто-нибудь решить мою проблему? Вот мой код:не может прочитать свойство 'channel' of null with simpleweather.js

<script type="text/javascript" src="/sites/dev/_catalogs/masterpage/NMSTheme/js/jquery-1.11.3.min.js"></script> 
     <script type="text/javascript" src="/sites/dev/_catalogs/masterpage/NMSTheme/js/jquery.simpleWeather.js"></script> 
     <script type="text/javascript" src="/sites/dev/_catalogs/masterpage/NMSTheme/js/yqlgeo.js"></script> 

<script type="text/javascript"> 

     $(document).ready(function() { 
      loadWeather(); 
      setInterval(loadWeather, 6000); 
     });  

     function loadWeather() { 
     debugger; 
      if(navigator.geolocation){ 

       navigator.geolocation.getCurrentPosition(function(position) { 

        var location = (position.coords.latitude + ',' + position.coords.longitude); 
        var woeid = undefined; 

        $.simpleWeather({ 
         location: location, 
         woeid: woeid, 
         unit: 'f', 
         success: function (weather) { 
         var time = ReturnCurrentTime(); 
         placehtml = '<span><h5>' + weather.city + ',' + weather.region + '</h5><span/>'; 
         datehtml = '<span><h5> ' + weather.forecast[0].day + ',' + time + '</h5><span/>'; 
         html = '<span><h5> ' + weather.temp + '&deg;' + ' ' + weather.units.temp + '</h5><span/>' ; 

         $("#date").html(datehtml); 
         $("#place").html(placehtml); 
         $("#weather").html(html); 
        }, 
        error: function (error) { 
         $("#weather1").html('<p>' + error + '</p>'); 
        } 
       }); 
      }); 
      } 
     }  
    </script> 
+0

Похоже, что они имеют некоторый t https://github.com/monkeecreate/jquery.simpleWeather/issues/101#issuecomment-173530978 – naoxink

ответ

3

Yahoo представила ошибку в запросе geo.placefinder. Используйте geo.places.

заменить линию 26 в simpleWeather.js с:

weatherUrl += 'select * from weather.forecast where woeid in (select woeid from geo.places where text="'+options.location+'" limit 1) and u="'+options.unit+'"'; 

Если вы звоните с геолокации Шир/объемного options.location со скобками:

$.simpleWeather({ 
    location: '(' + lat_long + ')', 

Посмотреть больше simpleWeather вопросов в Github :

https://github.com/monkeecreate/jquery.simpleWeather/issues/174

0

Yahoo, похоже, прекратил геолокации услуги, необходимые, чтобы найти место, основываясь на широте и долготе. Однако использование свойства woeid simpleWeather вместо местоположения все еще работает.

Смежные вопросы