Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.
jamesfleeting edited this page Sep 14, 2010 · 17 revisions

Welcome to the jquery.simpleWeather wiki!

A complete demo can be found at monkeeCreate

You must provide either a zip code (US only) or a location. Postal Code’s outside the US are not supported by the Yahoo Weather API (this is a limitation of the Yahoo YQL Weather API and not of this plugin) so you must use a location for international places. For example if your wanting London weather you would set the location to ‘london, united kingdom’. Yahoo API won’t recognize ‘london, uk’ so you must put the complete country.

Currently there are some locations that Yahoo! returns more then one spot for weather (example: a location of Melbourne, Australia will return the weather for Melbourne, Australia and Melbourne Airport, AS), in this case the plugin will return the first set of weather information (in this example, Melbourne, Australia weather would be displayed). However, this may not be correct all the time, if the wrong weather/location is being returned then you will need to specify the unique ID that Yahoo! has for each location. This ID can be found by going to http://weather.yahoo.com and searching for your location. Once on your location page there is an orange RSS icon, that is the url for that locations rss feed, in that url you will find a locations unique ID. Example: Wichita Falls, TX weather page is here, http://weather.yahoo.com/united-states/texas/wichita-falls-2520100/ and on that page is the rss icon which links here, http://weather.yahooapis.com/forecastrss?p=USTX1464&u=f. In that link you will notice the p= and that is the id, in this case its “USTX1464”. You then use that ID in simpleWeather in place of a zipcode (note the id will only work in the zipcode option, not location), zipcode: ‘USTX1464’. Although this has a few extra steps to get the plugin set up, it gives you control over exactly what location is displayed. Yahoo! doesn’t seem to provide a great way to get weather for outside the USA so this is what we are left with.

If you provide a zip code and a location, the location will take priority and will be used over zip code.

Usage

Basic Usage

$.simpleWeather({
	location: 'london, united kingdom',
	unit: 'c',
	success: function(weather) { ... },
	 error: function(error) { ... }
});
$.simpleWeather({,
        zipcode: '76309',
	unit: 'c',
	success: function(weather) { ... },
	 error: function(error) { ... }
});

Complete Usage

$.simpleWeather({
	zipcode: '76309',
	unit: 'f',
	success: function(weather) {
		$("#weather").append("<h2>"+weather.city+", "+weather.region+" "+weather.country+"</h2>");
		$("#weather").append("<p><strong>Today's High</strong>: "+weather.high+"&deg; "+weather.units.temp+" - <strong>Today's Low</strong>: "+weather.low+"&deg; "+weather.units.temp+"</p>");
		$("#weather").append("<p><strong>Current Temp</strong>: "+weather.temp+"&deg; "+weather.units.temp+"</p>");
		$("#weather").append("<p><strong>Wind</strong>: "+weather.wind.direction+" "+weather.wind.speed+" "+weather.units.speed+"</p>");
		$("#weather").append("<p><strong>Currently</strong>: "+weather.currently+" - <strong>Forecast</strong>: "+weather.forecast+"</p>");
		$("#weather").append('<p><img src="'+weather.image+'"></p>');
		$("#weather").append("<p><strong>Sunrise</strong>: "+weather.sunrise+" - <strong>Sunset</strong>: "+weather.sunset+"</p>");
		$("#weather").append("<p><strong>Last updated</strong>: "+weather.updated+"</p>");
		$("#weather").append('<p><a href="'+weather.link+'">View forecast at Yahoo! Weather</a></p>');
	},
	error: function(error) {
		$("#weather").html("<p>"+error+"</p>");
	}
});
Clone this wiki locally