Skip to content

Commit a78afd8

Browse files
author
Marek Dorda
committed
Update picker example
1 parent cd1f469 commit a78afd8

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

picker/script.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,35 @@ const options = {
66
};
77

88
windyInit(options, windyAPI => {
9-
const { picker, utils, broadcast } = windyAPI;
9+
const { picker, utils, broadcast, store } = windyAPI;
1010

11-
picker.on('pickerOpened', latLon => {
12-
// picker has been opened at latLon coords
13-
console.log(latLon);
14-
15-
const { lat, lon, values, overlay } = picker.getParams();
11+
picker.on('pickerOpened', ({ lat, lon, values, overlay }) => {
1612
// -> 48.4, 14.3, [ U,V, ], 'wind'
17-
console.log(lat, lon, values, overlay);
13+
console.log('opened', lat, lon, values, overlay);
1814

1915
const windObject = utils.wind2obj(values);
2016
console.log(windObject);
2117
});
2218

23-
picker.on('pickerMoved', latLon => {
19+
picker.on('pickerMoved', ({ lat, lon, values, overlay }) => {
2420
// picker was dragged by user to latLon coords
25-
console.log(latLon);
21+
console.log('moved', lat, lon, values, overlay);
2622
});
2723

2824
picker.on('pickerClosed', () => {
2925
// picker was closed
3026
});
3127

28+
store.on('pickerLocation', ({ lat, lon }) => {
29+
console.log(lat, lon);
30+
31+
const { values, overlay } = picker.getParams();
32+
console.log('location changed', lat, lon, values, overlay);
33+
});
34+
3235
// Wait since wather is rendered
3336
broadcast.once('redrawFinished', () => {
34-
picker.open({ lat: 48.4, lon: 14.3 });
3537
// Opening of a picker (async)
38+
picker.open({ lat: 48.4, lon: 14.3 });
3639
});
3740
});

0 commit comments

Comments
 (0)