Skip to Content
ExamplesLeaflet

MapsGL - Using MapsGL with Leaflet

This example demonstrates using MapsGL with the Leaflet  mapping library.

leaflet.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>MapsGL SDK - Using MapsGL with Leaflet</title> <meta name="description" content="Use MapsGL with a Leaflet map." /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css" crossorigin="" /> <script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js" crossorigin=""></script> <link href="https://cdn.aerisapi.com/sdk/js/mapsgl/1.9.0/aerisweather.mapsgl.css" rel="stylesheet" /> <script defer src="https://cdn.aerisapi.com/sdk/js/mapsgl/1.9.0/aerisweather.mapsgl.js"></script> <style> body, html { margin: 0; padding: 0; } #map { height: 100vh; width: 100%; } </style> </head> <body> <div id="map"></div> <script> window.addEventListener('load', () => { // Create the Leaflet map instance const map = L.map('map').setView([40, -85.5], 4); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); // Set up the MapsGL account const account = new aerisweather.mapsgl.Account('CLIENT_ID', 'CLIENT_SECRET'); // Create the Leaflet map Controller const controller = new aerisweather.mapsgl.LeafletMapController(map, { account }); controller.on('load', () => { // Do stuff, like add weather layers controller.addWeatherLayer('radar'); controller.addWeatherLayer('alerts-outline', { paint: { opacity: 0.5 } }); }); }); </script> </body> </html>
© 2026 Xweather (opens in a new tab)Terms of Service (opens in a new tab)Privacy Policy (opens in a new tab)