Using MapsGL with Mapbox GL
This example demonstrates using MapsGL with the Mapbox GL (opens in a new tab) mapping library.
mapbox.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>MapsGL SDK - Using MapsGL with Mapbox GL</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://api.mapbox.com/mapbox-gl-js/{% $versions.mapbox.current %}/mapbox-gl.css" rel="stylesheet" />
<script defer src="https://api.mapbox.com/mapbox-gl-js/{% $versions.mapbox.current %}/mapbox-gl.js"></script>
<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 Mapbox map instance
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v11',
center: [-85.5, 40],
zoom: 3,
projection: 'mercator'
});
// create the account
const account = new aerisweather.mapsgl.Account('CLIENT_ID', 'CLIENT_SECRET');
// create the Mapbox Map Controller
const controller = new aerisweather.mapsgl.MapboxMapController(map, { account });
controller.on('load', () => {
// do stuff, like add weather layers
controller.addWeatherLayer('radar');
});
});
</script>
</body>
</html>