JavaScript Library

The Simcoe Weather JavaScript client library allows you to access various features of the Simcoe Weather Platform through JavaScript. You can make Simcoe Weather API calls through JavaScript from any website and easily create AJAX applications. Since the library does not require any server side code, you can now create a weather application that can be hosted on any website.

Features

The library supports most existing Simcoe Weather API methods. The response of the data is always in JSON format.

Supported Browsers

The following browsers are currently supported:
» Firefox 3
» Internet Explorer 6, 7 & 8
» Safari 3
» Opera 9
» Google Chrome

Download

You can download the JavaScript Client Library here.

Getting Started

1. In your html page add the following script tag into the head of the page.
<script type="text/javascript" src="SimcoeWeatherAPI.js"></script>

2. Within a script tag or external .js file write a function that will get the weather data with some parameters included. The parameter "callback" will execute the function of you choice. If you dont specify it you wont be able to do anything with the response data.
<script type="text/javascript">
//loads the data from the rest server
SimcoeWeatherAPI.localforecast_get({
parameters: {
callback: "getResults",
location: "Barrie"
}
});


//the callback function specified above in the "callback" parameter
function getResults(obj) {
alert(obj.sw.status);
}
</script>