Display a LegendView
Render a legend view. The following example will display a legend view for the radar and storm reports layers.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Xweather JavaScript SDK - Basic LegendView</title>
<script defer src="https://cdn.aerisapi.com/sdk/js/latest/aerisweather.min.js"></script>
<link rel="stylesheet" href="https://cdn.aerisapi.com/sdk/js/latest/aerisweather.css">
<style>
#legend {
font-family: 'Helvetica','Arial',sans-serif;
margin: 30px auto;
width: 400px;
}
.awxjs__legend-view > .awxjs__legend {
border-bottom: 1px solid #eee;
padding: 8px 0;
}
.awxjs__legend-view > .awxjs__legend:first-child {
border-top: 1px solid #eee;
}
</style>
</head>
<body>
<div id="legend"></div>
<script>
window.onload = () => {
const aeris = new Xweather('CLIENT_ID', 'CLIENT_SECRET');
aeris.views().then(views => {
const legend = new views.Legend(document.getElementById('legend', {
size: {
width: 400
}
}));
legend.set(['radar', 'stormreports']);
});
};
</script>
</body>
</html>