Windy Community

    • Register
    • Login
    • Search
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    1. Home
    2. jalbert
    3. Best
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 6
    • Best 3
    • Controversial 0
    • Groups 1

    Best posts made by jalbert

    • adding zoomed-in layers in api v4

      Dear Windy team,

      Just FYI I've been waiting a week or so to post this because I thought it might possibly be fixed in updates, or perhaps be redundant with other people's questions or preliminary bug reports(?), but when I try to add zoomed-in layers in API v4, via either (for example):

        L.tileLayer('http://b.tile.openstreetmap.org/{z}/{x}/{y}.png', {
          attribution: 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, ',
          maxZoom: 17,
          minZoom: 12
        }).addTo(map);
      

      or within the API initialization itself:

      const options = {
      
                  // Required: API key
                  key: 'OznecmCq1hd17S4F3e5rtotajmkUBw2D',
      
                  // Put additional console output
                  verbose: true,
      
                  // Optional: Initial state of the map
            lat:   48.46,
            lon: -123.31,
            zoom: 11,
            layers: [
              L.tileLayer('http://b.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                minZoom: 12,
                maxZoom: 17,
                attribution: 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, '
              })
            ],
            minZoom: 0,
            maxZoom: 17
      }
      
      // Initialize Windy API
      windyInit( options, windyAPI => {
      

      ... etc ...

      then those zoomed-in layers do not get added to the map (or at least are not accessible via the usual zoom buttons) -- whereas the above work fine in v2.3. Am I doing something wrong? -- do these layer additions need to be done differently in API v4?

      Thank you all so much!
      Justin

      posted in Windy API v4
      J
      jalbert
    • RE: Zoom is limited to level 11

      OK, thanks, I have this working now -- specifically in the lines right after :

      // Initialize Windy API
      windyInit( options, windyAPI => {
          // windyAPI is ready, and contains 'map', 'store',
          // 'picker' and other useful stuff
          // const { map } = windyAPI
          var { map } = windyAPI
          // .map is instance of Leaflet map
      

      the code added to get it working is:

          map.options.minZoom = 4;
          map.options.maxZoom = 17;
      
          var topLayer = L.tileLayer('http://b.tile.openstreetmap.org/{z}/{x}/{y}.png', {
              attribution: 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, ',
              minZoom: 12,
              maxZoom: 17
          }).addTo(map);
          topLayer.setOpacity('0');
      
          map.on('zoomend', function() {
              if (map.getZoom() >= 12) {
                  topLayer.setOpacity('1');
              } else {
                  topLayer.setOpacity('0');
              }
          });
          map.setZoom(14);
      

      and it now works for me. (Adding the minZoom and maxZoom settings to the const options = { ... } settings before the WindyInit, or any code before var { map } = windyAPI in the WindyInit, did not work for me.) Thanks!

      (BTW, I'll have a couple more questions later on a couple of other Windy API4 / Leaflet minor issues I'm having that are unrelated to the zoom levels.)

      Thank you very very much!!!
      justin

      posted in Windy API v4
      J
      jalbert
    • RE: Zoom is limited to level 11

      Exact same issue here as well. I also asked about this in:
      https://community.windy.com/topic/6580/adding-zoomed-in-layers-in-api-v4

      and other people have also asked about this problem in other threads, but no one yet has mentioned a fix (or API update) for this issue so far I believe...

      posted in Windy API v4
      J
      jalbert