A full featured directions plugin for mapbox-gl-js using the Mapbox Directions API.
var mapboxgl = require('mapbox-gl');
var MapboxDirections = require('@mapbox/mapbox-gl-directions');
var directions = new MapboxDirections({
accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
unit: 'metric',
profile: 'cycling'
});
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9'
});
map.addControl(directions, 'top-left');
Live example: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
See API.md for complete reference.
See CONTRIBUTING.md.