Windy Community

    • Register
    • Login
    • Search
    • Unread
    • Categories
    • Groups
    • Go to windy.com

    Unsolved Picker API behavior

    Windy API v4
    2
    2
    245
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      serbekh last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • rittels
        rittels Code contributor | Premium last edited by

        try:

        broadcast.fire("rqstOpen","picker", { lat:-30, lon:30 });
        broadcast.fire("rqstClose","picker");
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
        NodeBB & contributors, OSM & contributors, HERE maps
        Terms and Conditions     Privacy Policy