Windy Community
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    • Register
    • Login

    Is there a way to retrieve user's favorite locations

    Scheduled Pinned Locked Moved Windy Plugins
    4 Posts 3 Posters 2.0k Views 1 Watching
    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.
    • vicbV Offline
      vicb Paraglider | Premium
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • siimS Offline
        siim
        last edited by

        if (localStorage && localStorage.getItem('favs')) {
          var favs = JSON.parse(localStorage.getItem('favs'));
          console.log(Object.values(favs));
        }
        
        ivoI 1 Reply Last reply Reply Quote 1
        • ivoI Offline
          ivo Windy Staff @siim
          last edited by

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

          1 Reply Last reply Reply Quote 1
          • vicbV Offline
            vicb Paraglider | Premium
            last edited by vicb

            Thanks @ivo

            So the "better" way to retrieve favorites is

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

            Then

            favs.getAll();
            

            returns:

            { 
              "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", …},
              …
            }
            

            and

            favs.getArray();
            

            returns:

            [
              {key: "37.514/-121.882", lat: 37.513810842731, lon: -121.88215255737303, name: "Mission Peak", type: "fav", …},
              {key: "37.365/-122.246", lat: 37.3650410873092, lon: -122.24594593048094, name: "Windy Hill", type: "fav", …},
              {key: "34.492/-119.702", lat: 34.491843534372784, lon: -119.70239639282227, name: "Santa Barbara", type: "fav", …},
              …
            ]
            
            1 Reply Last reply Reply Quote 2
            • First post
              Last post
            Windy Community  |  Powered by excellent NodeBB
            Terms of Use     Privacy Policy     Windy.com