Windy Community

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

    Is there a way to retrieve user's favorite locations

    Windy Plugins
    3
    4
    851
    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.
    • vicb
      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
      • siim
        siim last edited by

        if (localStorage && localStorage.getItem('favs')) {
          var favs = JSON.parse(localStorage.getItem('favs'));
          console.log(Object.values(favs));
        }
        
        ivo 1 Reply Last reply Reply Quote 1
        • ivo
          ivo Administrator @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
          • vicb
            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
            Windyty, S.E. - all rights reserved. Powered by excellent NodeBB
            NodeBB & contributors, OSM & contributors, HERE maps
            Terms and Conditions     Privacy Policy