The Morfik Weather Feed package contains a single widget (Weather Feed) that displays local weather information for a specified location. The widget can display the current temperature, an image related to the weather conditions, the high and low temperatures, wind conditions and a link to Yahoo! Weather’s complete forecast for the area.
A Quick Walkthrough
To use the Morfik Weather Feed package simply add the package to the project by utilizing the “Used Packages” command on the project ribbon (see Figure 1 Used Packages Command), or simply drag the package file onto the application main client area. Once added a single widget will appear on the home ribbon when the form designer is active (see Figure 2 Widgets List). This widget can be placed on application forms and provide immediate functionality with minimal coding.
|Figure 1: Used Packages Command|
|Figure 2: Widget Gallery|
A Quick Walkthrough – Using the Weather Feed widget
To get started, open a new Morifk 3 application and add the Weather Feed package. On a form, add a Weather Feed widget and you form should look like Figure 3 – Default Weather Feed Widget. Set the wf Placename to “UKXX0085” (See Specifying a Location below).
|Figure 3: Default Weather Feed Widget|
When the page is previewed, it should look like Figure 4 – London Weather (if it’s raining, which it likely is).
|Figure 4: London Weather|
Specifying a Location
A location code is of the form AAXX9999 where AA is a country code, XX is a country subcode (if necessary) and 9999 is a number code with leading zeroes. To determine a code for a location (if one exists), browse to http://weather.yahoo.com/ and search for the desired location (you may have to select between multiple locations). If you find the location, open up the weather feed for that location and click on the RSS feed button. The URL for the feed should contain a parameter similar to p=USCA0326 (East Irvine, California) or p=ASXX0332 (Hobart, Tasmania).
If the Placename parameter is specified incorrectly, you may get the error returned “Script Error: feed.wind is undefined”.
Weather Feed properties
The information that is displayed on the widget can be controlled through the following properties: wf High Low, wf Image, wf Link, wf Show Error, wf Units and wf Wind. Wf Units determines if the temperature will be displayed in Celsius or Fahrenheit and the other properties control whether the related items will be visible.
The weather feed package provides an interface to the service described at http://www.zazar.net/developers/zweatherfeed/. By studying the implementation of this service you can gain valuable insight into how to utilize similar services in your own code.