JSFiddle - React, Tailwind, and code Playground
by Tristen Brown
HTML
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox-gl-js/v2.9.0-beta.1/mapbox-gl.css">
<link rel="stylesheet" href="https://api.mapbox.com/mapbox-assembly/mbx/v1.2.0/assembly.min.css">
<script src="https://gistcdn.githack.com/tristen/9ec73d3009d1ef77481d2f945ac65729/raw/fbe19cd1b6fc3ea75de8334fc9b08734a86053b5/index.js"></script>
<div id="map" class="absolute top bottom left right w-full"></div>
JavaScript
mapboxgl.accessToken = 'pk.eyJ1IjoidHJpc3RlbiIsImEiOiJjajZoOXU4Z2kwNnppMnlxd2d6bTFvZ2xtIn0.PP7AoUakMfeqdXFHdsY0oA';
const a = {
"version": 8,
"zoom": 1,
"name": "xray",
"sources": {
"composite": {
"url": "mapbox://mapbox.mapbox-streets-v8",
"type": "vector"
}
},
"sprite": "mapbox://sprites/mapbox/streets-v11",
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
"projection": {"name": "globe"},
"layers": [
{
"id": "bg",
"type": "background",
"paint": {"background-color": "#0F2127"}
},
{
"id": "water",
"type": "fill",
"source": "composite",
"source-layer": "water",
"paint": {
"fill-color": "#000"
}
}
]
};
const map = new mapboxgl.Map({
container: 'map',
style: a
});
map.on('move', () => {
console.log(map.getBounds());
});