Is there a way to retrieve user's favorite locations


  • Paraglider

    I'd like to add quick jump to favorites to my sounding plugin.

    Is there a way to retrieve them ? ie from the store ?

    Thanks



  • if (localStorage && localStorage.getItem('favs')) {
      var favs = JSON.parse(localStorage.getItem('favs'));
      console.log(Object.values(favs));
    }
    

  • Administrator

    @siim There is module fav. Try to use this module and access favs this way. It has methods te retrieve all favs as Array.


  • Paraglider

    Thanks @ivo

    So the "better" way to retrieve favorites is

    import favs from "@windy/favs"; 
    // or
    // var favs = W.require('favs');
    
    favs.getAll();
    

    It returns an object

    { 
      "34.492/-119.702": {key: "34.492/-119.702", lat: 34.491843, lon: -119.702396, name: "Santa Barbara", type: "fav", …},
      "36.768/-119.098": {key: "36.768/-119.098", lat: 36.768385, lon: -119.097719, name: "Dunlap", type: "fav", …}
      ...
    }
    

Log in to reply
 

Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
NodeBB & contributors, OSM & contributors, HERE maps