Picker API behavior



  • I try to run windy picker example:

    
    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', () => {
            console.log('picker was closed!')
        });
    
        // Wait since wather is rendered
        broadcast.once('redrawFinished', () => {
            picker.open({ lat: 48.4, lon: 14.3 });
            // Opening of a picker (async)
        });
    });
    

    It loads great!
    When I wanted to use other methods, something went wrong...
    For example, I tried to open it, close it and open it again:

    ...
        broadcast.once('redrawFinished', () => {
            picker.open({ lat: 48.4, lon: 14.3 });
            picker.close();
            picker.open({ lat: 45.4, lon: 45.3 });
            // Opening of a picker (async)
        });
    ...
    
    1. when I try to execute picker.close(), nothing happens. (It should print 'picker was closed!' to console)
    2. This message ('picker was closed!') appears only on click on cross sign near picker.
    3. After that I tried to run picker.open({ lat: 48.4, lon: 14.3 }) again, bun I've got another error:
    Uncaught TypeError: this.show is not a function
        at Object.open (picker.js:4)
        at NewClass.eval (Map.vue?108f:99)
        at NewClass.fire (leaflet-src.js?e11e:593)
        at NewClass._fireDOMEvent (leaflet-src.js?e11e:4425)
        at NewClass._handleDOMEvent (leaflet-src.js?e11e:4382)
        at HTMLDivElement.handler (leaflet-src.js?e11e:2658)
    

    So, question is how to close and open picker again programmatically.


  • Code contributor

    try:

    broadcast.fire("rqstOpen","picker", { lat:-30, lon:30 });
    broadcast.fire("rqstClose","picker");
    

Log in to reply
 

Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
NodeBB & contributors, OSM & contributors, HERE maps
Terms and Conditions     Privacy Policy