binding from mapbox gl to the leaflet api
npm install mapbox-gl-leafletNote: this tool is experimental and is not actively supported by Mapbox. For support, please open an issue in this repository.

This is a binding from Mapbox GL JS to the familiar
Leaflet API.
javascript
// replace with your Mapbox API Access token. Only include a token if you will be using Mapbox tiles.
var token ="pk.XXXX";var map = L.map('map').setView([38.912753, -77.032194], 15);
L.marker([38.912753, -77.032194])
.bindPopup("Hello Leaflet GL!
Whoa, it works!")
.addTo(map)
.openPopup();
var gl = L.mapboxGL({
accessToken: token,
style: 'mapbox://styles/mapbox/bright-v8'
}).addTo(map);
`
Note that you can use any vector tile source useable by mapbox-gl. For instance, you can use OSM2VectorTiles with:
`javascript
var gl = L.mapboxGL({
style: 'https://api.maptiler.com/maps/topo/style.json?key='
}).addTo(map);
`Once you have created the leaflet layer, the mapbox-gl map object can be accessed using
`javascript
gl.getMapboxMap()....
// add a source to the mapbox-gl layer
gl.getMapboxMap().addSource({...})
`Get your Mapbox token
Create a mapbox account, then head to https://www.mapbox.com/studio/ and copy your access token that was automatically created for you. The access token should start with "pk.".Live examples
Basic exampleCode for these examples is hosted in the examples folder
Installation
Add a script tag referencing mapbox-gl-leaflet after adding leaflet and mapbox-gl-js in your website:
`html
`
You can also use Unpkg as a CDN using:
`html
``On the bright side, the mapbox-gl-leaflet binding will allow you to use all the leaflet features and plugins.
If you only need the mapbox-gl-js features (adding a map with a mapbox-style, adding a GeoJSON, etc.), you are probably better off using it directly.