@mapbox/mapbox-gl-directions

4.3.0 • Public • Published

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.

Usage

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

var directions = new MapboxDirections({
  accessToken: 'YOUR-MAPBOX-ACCESS-TOKEN',
  unit: 'metric',
  profile: 'mapbox/cycling'
});

var map = new mapboxgl.Map({
  container: 'map'
});

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

Live example: https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/

Deeper dive

See API.md for complete reference.

Contributing

See CONTRIBUTING.md.

Package Sidebar

Install

npm i @mapbox/mapbox-gl-directions

Weekly Downloads

5,099

Version

4.3.0

License

ISC

Unpacked Size

443 kB

Total Files

49

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user