forked from windycom/API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
37 lines (30 loc) · 979 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 !!!
lat: 50.4,
lon: 14.3,
zoom: 5,
};
windyInit(options, windyAPI => {
const { picker, utils, broadcast } = windyAPI;
picker.on('pickerOpened', latLon => {
// picker has been opened at latLon coords
console.log(latLon);
const { lat, lon, values, overlay } = picker.getParams();
// -> 48.4, 14.3, [ U,V, ], 'wind'
console.log(lat, lon, values, overlay);
const windObject = utils.wind2obj(values);
console.log(windObject);
});
picker.on('pickerMoved', latLon => {
// picker was dragged by user to latLon coords
console.log(latLon);
});
picker.on('pickerClosed', () => {
// picker was closed
});
// Wait since wather is rendered
broadcast.once('redrawFinished', () => {
picker.open({ lat: 48.4, lon: 14.3 });
// Opening of a picker (async)
});
});