Skip to Content
ExamplesMap Units

MapsGL - Setting map units

xxxxxxxxxx

map-units.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>MapsGL SDK - Setting map units</title> <meta name="description" content="Set the default units of data displayed on the map." /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="https://api.mapbox.com/mapbox-gl-js/v3.12.0/mapbox-gl.css" rel="stylesheet" /> <script defer src="https://api.mapbox.com/mapbox-gl-js/v3.12.0/mapbox-gl.js"></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', () => { mapboxgl.accessToken = 'MAPBOX_TOKEN'; const map = new mapboxgl.Map({ container: document.getElementById('map'), style: 'mapbox://styles/mapbox/light-v9', center: [-122.33207, 47.60621], zoom: 8 }); const account = new aerisweather.mapsgl.Account('CLIENT_ID', 'CLIENT_SECRET'); // Configure the map to use metric units by default const controller = new aerisweather.mapsgl.MapboxMapController(map, { account, units: { temperature: 'C', speed: 'km/h', distance: 'km', pressure: 'mb' } }); controller.on('load', () => { // Hide Mapbox's labels since we're adding a weather text layer controller.map.style.stylesheet.layers.forEach(function(layer) { if (layer.type === 'symbol') { controller.map.setLayoutProperty(layer.id, 'visibility', 'none'); } }); // add the temperature text weather layer controller.addWeatherLayer('temperatures-text'); }); }); </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)