Directions plugin for mapbox-gl-js using Mapbox Directions API.
Clone or download
tristen Release V4.0.0 (#204)
* Update release instructions

* Add v4.0.0 notes to changelog

* 4.0.0
Latest commit 4e2cf7c Dec 18, 2018

Mapbox GL Directions

A full featured directions plugin for Mapbox GL JS using the Mapbox Directions API. Quickly add UI to display driving, cycling, or walking directions on the map. The Mapbox Directions API is powered by the OSRM routing engine and open data from the OpenStreetMap project.

For directions functionality in native mobile and desktop applications, see Mapbox Android Services, MapboxDirections.swift, and MapboxNavigation.swift.


var mapboxgl = require('mapbox-gl');
var MapboxDirections = require('@mapbox/mapbox-gl-directions');

var directions = new MapboxDirections({
  unit: 'metric',
  profile: 'mapbox/cycling'

var map = new mapboxgl.Map({
  container: 'map',
  style: 'mapbox://styles/mapbox/streets-v9'

map.addControl(directions, 'top-left');

Live example:

Deeper dive

See for complete reference.