Change of metric

Each ovelay has its own object instance, residing in W.overlays.overlay_name. To change metric for particular overlay use W.overlays.overlay_name.setMetric( ident ) method, where ident is identifier of new metric.

User can change matric by clicking on a legend on a right side.

Change of metric produces metricChanged message.

Allowed metric values:

    wind: ['kt','bft','m/s','mph','km/h'],
    temp: ['°C','°F'],
    pressure: ['hPa','inHg'],
    clouds: ['mm','in'],
    waves, swell: ['m','ft']

Source code

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script>
    <style type="text/css">
      #windyty {    height: 500px; width: 1000px; 
                    margin-left: auto; margin-right: auto;
                    position: relative;
                    margin-top: 50px; }
    </style>
  </head>
  <body>
    <div id="windyty"></div>

    <script type="text/javascript">
          
    var windytyInit = { key: 'PsL-At-XpsPTZexBwUkO7Mx5I' }  

    function windytyMain(map) {

      var metrics = ['kt','bft','m/s','mph','km/h'],
      actual = 0;

      setInterval(function(){
        actual++;
        if(actual > metrics.length) actual = 0;
        W.overlays.wind.setMetric( metrics[ actual ] );
      },2000)
    }

    </script>

    <script async defer src="https://api.windytv.com/v2.3/boot.js"></script> 
  </body>
</html>