-
Notifications
You must be signed in to change notification settings - Fork 188
/
script.js
37 lines (28 loc) · 900 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const options = {
key: 'PsLAtXpsPTZexBwUkO7Mx5I', // REPLACE WITH YOUR KEY !!!
// Changing Windy parameters at start-up time
// (recommended for faster start-up)
lat: 50.4,
lon: 14.3,
zoom: 5,
timestamp: Date.now() + 3 * 24 * 60 * 60 * 1000,
hourFormat: '12h',
// ...etc
};
windyInit(options, windyAPI => {
const { store } = windyAPI;
// All the params are stored in windyAPI.store
const levels = store.getAllowed('availLevels');
// levels = ['surface', '850h', ... ]
// Getting all available values for given key
let i = 0;
setInterval(() => {
i = i === levels.length - 1 ? 0 : i + 1;
// Changing Windy params at runtime
store.set('level', levels[i]);
}, 500);
// Observing change of .store value
store.on('level', level => {
console.log(`Level was changed: ${level}`);
});
});