duanchun1852 2013-06-20 17:05
浏览 17
已采纳

NWS Weather Module API

I'm using the NWS Weather module. The builtin block works great but I want to display the current temperatures from two other nearby cities. In the readme file they state.

The block defined by NWS_weather allows simple access to weather forecast data for one point. Developers who would like to retrieve data for multiple points or who wish to retrieve more data (wind speed, wind direction, etc.) can utilize this module by calling this function:

$forecast=nws_weather_NDFDgen($lat, $lon, array('wdir', 'temp', 'maxt', 'mint'), "time-series", "2009-12-08T12:00:00", "2009-12-09T12:00:00");

I'm not a developer and have no idea how to use this. I'm wondering if someone could give me some sample code I could work with. I'm working with the 7.x-1.3 version. Thanks guys.

https://drupal.org/project/nws_weather

  • 写回答

1条回答 默认 最新

  • doutou7286 2013-06-24 10:29
    关注

    Please follow the steps:

    1. If you haven't the "PHP filter" module enabled, enable it.
    2. Create a custom "Block".
    3. Set body content as following:

    <?php
    
    $forecast = nws_weather_NDFDgenByDay('47.53', '-122.30');
    
    echo theme('nws_weather_forecast', 
              array(
                'dataForecast' => $forecast, 
                'required' => array('Daily Maximum Temperature', 'Daily Minimum Temperature', 'Conditions Icons', ), 
                'display' => array('Conditions Icons', 'Weather Type, Coverage, and Intensity', 'Daily Maximum Temperature', 'Daily Minimum Temperature', )
              )
    );
    
    ?>
    

    Here, 47.53 is lat or latitude and -122.30 is long or longitude. You can also pass day count to display for specific days. Like:

    $forecast = nws_weather_NDFDgenByDay('47.53', '-122.30', 7);

    This will load updates for 7 days.

    Then save the Block. And set the currently created block to any region. See the result in front-end. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器