Skip to Content
ExamplesUsing With Mapbox

Raster Maps - Using with Mapbox GL

The following provides an example of Xweather Raster Maps radar layer integrated with the Mapbox GL JS SDK  library.

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Xweather Raster Maps - Mapbox Example</title> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <style> body { margin:0; padding:0; } #map { position:absolute; top:0; bottom:0; width:100%; } </style> <link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.28.0/mapbox-gl.css" rel="stylesheet" /> <script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.28.0/mapbox-gl.js"></script> </head> <body> <div id="map"></div> <script> mapboxgl.accessToken = "MAPBOX_TOKEN"; var tileset = "mapbox.streets"; var map = new mapboxgl.Map({ container: "map", style: "mapbox://styles/mapbox/streets-v8", center: [-95.7, 37.1], // starting position zoom: 3 // starting zoom }); map.on("load", function () { map.addSource("xweather-radar", { "type": "raster", "tiles": [ "https://maps.api.xweather.com/{client_id}_{client_secret}/radar/{z}/{x}/{y}/current.png", ], "tileSize": 256, "attribution": "<a href="https://www.xweather.com/">Xweather</a>" }); map.addLayer({ "id": "radar-tiles", "type": "raster", "source": "xweather-radar", "minzoom": 0, "maxzoom":22 }); }); </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)