I would love to see how you pull the data! I'd like to apply that to pulling images from another department in our company on a particular, automated schedule.
Hi,
I was inspired by this dynamic weather feature. Did not find any reply from the author. Did some research and here is the soul of the basic solution:
On a Execute JavaScript Trigger:
function Get(dataURL){
var Httpreq = new XMLHttpRequest();
Httpreq.open("GET", dataURL, false);
Httpreq.send(null);
return Httpreq.responseText;
}
//get your API ID from openweathermap.org. You need to read about the API structure. For now I am only using the URL for Current Weather Data:
var dataURL = "http://api.openweathermap.org/data/2.5/weather?id=4044019&&units=metric&appid=get API ID from openweathermap.org";
var json_obj = JSON.parse(Get(dataURL));
//you'll need to install a JSON viewer extension on your browser to view the JSON structure so you c... Expand
Hi,
I was inspired by this dynamic weather feature. Did not find any reply from the author. Did some research and here is the soul of the basic solution:
On a Execute JavaScript Trigger:
function Get(dataURL){
var Httpreq = new XMLHttpRequest();
Httpreq.open("GET", dataURL, false);
Httpreq.send(null);
return Httpreq.responseText;
}
//get your API ID from openweathermap.org. You need to read about the API structure. For now I am only using the URL for Current Weather Data:
var dataURL = "http://api.openweathermap.org/data/2.5/weather?id=4044019&&units=metric&appid=get API ID from openweathermap.org";
var json_obj = JSON.parse(Get(dataURL));
//you'll need to install a JSON viewer extension on your browser to view the JSON structure so you can easily access the variables:
var cityName = json_obj.name;
var wthrDesc = json_obj.weather[0].description;
var wthrIcon = json_obj.weather[0].icon;
var wthrTemp = json_obj.weather[0].temp;
var player = GetPlayer();
player.SetVar("CityName", cityName);
player.SetVar("WeatherDesc", wthrDesc);
player.SetVar("WeatherIcon", wthrIcon);
player.SetVar("WeatherTemp", wthrTemp);
// make sure you have created the variables from within your project in Storyline. That's it.
Hi R F,
thank you very much for this nice work! Do you have an idea how the WeatherIcon from openweathermap can be displayed in Storyline? I really like this and try to play around with it a bit.
Hi Stefan. Thank you for having interest on my solution.
For the icon to appear. I have created a rectangle.
Then I just changed the state depending on the value of the:
var wthrIcon = json_obj.weather[0].icon;
Here's the trigger wizard:
Action: Change state of
On object: Rectangle
To state: 04n // this is the value I got from the JSON
When: timeline start
Object: Rectangle
On condition: wIcon == Equal to (ignore case) 04n
I wish I can send attach the screen-shot here.
Hey R F, thank you for your reply! I am quite new to js and sl. But I really like learning these things. I have already found the same solution and I am happy about your confirmation!
16 Comments
Hi, I was inspired by this dynamic weather feature. Did not find any reply from the author. Did some research and here is the soul of the basic solution: On a Execute JavaScript Trigger: function Get(dataURL){ var Httpreq = new XMLHttpRequest(); Httpreq.open("GET", dataURL, false); Httpreq.send(null); return Httpreq.responseText; } //get your API ID from openweathermap.org. You need to read about the API structure. For now I am only using the URL for Current Weather Data: var dataURL = "http://api.openweathermap.org/data/2.5/weather?id=4044019&&units=metric&appid=get API ID from openweathermap.org"; var json_obj = JSON.parse(Get(dataURL)); //you'll need to install a JSON viewer extension on your browser to view the JSON structure so you c... Expand