Source code
Download complete example from GitHub
HTML
<html>
<head>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, shrink-to-fit=no"
/>
<script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"></script>
<script src="https://api.windy.com/assets/map-forecast/libBoot.js"></script>
<style>
#windy {
width: 100%;
height: 300px;
}
</style>
</head>
<body>
<div id="windy"></div>
<script src="script.js"></script>
</body>
</html>
JavaScript
const options = {
key: 'PsLAtXpsPTZexBwUkO7Mx5I',
};
windyInit(options, windyAPI => {
const { overlays, broadcast } = windyAPI;
const windMetric = overlays.wind.metric;
console.log(windMetric);
overlays.wind.listMetrics();
overlays.wind.setMetric('bft');
broadcast.on('metricChanged', (overlay, newMetric) => {
console.log(overlay, newMetric);
});
});