.overlays: change of overlay's metrics

Each Windy's overlay has its own object in windyApi.overlays modules. Use these objects to change overlay's metric. For example for wind overlay, use read only value overlays.wind.metric to get actual value, .listMetrics() to get allowed ones, and .setMetric(metric) to set metric to the new value.

Source code

    <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"></script>
    <script src="https://api4.windy.com/assets/libBoot.js"></script>
  		#windy {
  			width: 100%;
  			height: 300px;
    <div id="windy"></div>

      const options = {
        key: 'PsLAtXpsPTZexBwUkO7Mx5I'

      windyInit( options, windyAPI => {

        // All the params are stored in windyAPI.store
        const { overlays, broadcast } = windyAPI

        var windMetric = overlays.wind.metric
        // 'kt' .. actually selected metric for wind overlay
        // Read only value! Do not modify.

        // ['kt', 'bft', 'm/s', 'km/h', 'mph'] .. available metrics

        // Metric for wind was changed to bft

        broadcast.on('metricChanged', (overlay,newMetric) => {

          // Any changes of any metric can be observed here



Fork me on GitHub