Jon Garrido Martin GIS Developer

GIS Developer Freelance

API Rest Forecast.IO

By jongarrido | September 2, 2015 | 0 Comment

In this post I’ll explaine how to access to Forest.io Api Rest using esri.request call.

It’s as simple as make the call and mange the callback function:

var url = 'https://api.forecast.io/forecast/yourapikeyXXXXX/';
var latlon = [feature.geometry.getLatitude(),feature.geometry.getLongitude()].join(',');var req = esri.request({
url: url + latlon,
content: {
units: 'si' // celsius, km/h
},
handleAs: "json",
callbackParamName: "callback"
});

The event to mange the callback:
req.then(function(data)
{
//some examples
console.log(data.currently.summary)  // Weather summary for now..
console.log( data.daily.data[0].summary)  // Weather summary for tomorrow..
console.log(data.currently.windBearing) // Azimut for current wind ...
},
function(error)
{
console.log(error);
});

Thanks to Javier Abadia (ESRI Spain) for his demo at the ESRI user conference 2013 in Madrid.

A simple example: here

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *