Using MapsGL with MapLibre
This example demonstrates using MapsGL with the MapLibre (opens in a new tab) mapping library.
maplibre.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>MapsGL SDK - Using MapsGL with MapLibre</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/maplibre-gl@{% $versions.maplibre.current %}/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@{% $versions.maplibre.current %}/dist/maplibre-gl.css" rel="stylesheet" />
<script defer src="{% $paths.sdk %}"></script>
<style>
#map {
height: 600px;
margin: 30px auto;
width: 1200px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
window.addEventListener('load', () => {
// create the Maplibre map instance
const map = new maplibregl.Map({
container: 'map',
style: 'https://api.maptiler.com/maps/streets-v2-light/style.json?key=MAPTILER_KEY',
center: [-85.5, 40],
zoom: 3
});
// create the account
const account = new aerisweather.mapsgl.Account('CLIENT_ID', 'CLIENT_SECRET');
// create the Maplibre Map Controller
const controller = new aerisweather.mapsgl.MaplibreMapController(map, { account });
controller.on('load', () => {
// do stuff, like add weather layers
controller.addWeatherLayer('radar');
});
});
</script>
</body>
</html>