Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vietmap-gl-directions

mapbox22ISCdeprecated1.1.8

this package has been deprecated

A mapboxgl plugin for the Mapbox Directions API

directions, routing, osm, gl

readme

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',
  style: 'mapbox://styles/mapbox/streets-v9'
});

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.

changelog

4.0.3

  • Adds exclude parameter #233

4.0.2

4.0.1

  • Update packages to resolve polyline dependency
  • Update peerDependency for Mapbox-GL-JS to support v1.0 release
  • Switch to yarn to workaround sockjs-client dependency issue

4.0.0

  • [Refactor] options passed to internal Geocoder class
    • Made options.geocoder dynamic, accepting only query parameters from the Geocoding API
    • Removed placeholder option in favor of placeholderOrigin and placeholderDestination
    • Added top level options flyTo, zoom, placeholderOrigin and placeholderDestination
  • [Chore] Update packages to resolve vulnerabilities in smokestack

3.1.3

  • [bug] Bump package suggestions to support autocompletion on quick keypress.#179

3.1.2

  • [workaround] Include /dist directory in published NPM package

3.1.1

  • [bug] Fixes css for turn instruction icons

3.1.0

  • [internal] upgrade to v5 of the Mapbox Directions API
  • [feature] add traffic aware driving directions profile

3.0.3

  • [bug] re-enable hiding instructions panel #101

3.0.2

  • [bug] Fixing a fix for 3.0.1. Missed a single space.

3.0.1

  • [bug] CSS fix for departure/arrival icons that were not center aligned because of global line-height properties

3.0.0

Support for the Mapbox GL JS 0.27.0 API. This is compatible with 0.27.0 and later, and not compatible with earlier versions.

  • [breaking] container option removed - attaching the control outside of the map is no longer supported
  • [breaking] position option removed - the addControl method now specifies the position
  • [breaking] Now exports MapboxDirections rather than attaches to mapbox.Directions
  • [internal] no longer creates a new map control for each of the two geocoders, instead creates two internal geocoders
  • [feature] removeRoutes method that removes all route lines, waypoints, and instructions

2.2.0

2.1.0

  • [bug] Warn if mapboxgl is not present #66
  • [bug] Point main in package.json to transpiled result #63
  • [feature] Wrap coordinates outside of -180, 180 [#54]((https://github.com/mapbox/mapbox-gl-directions/issues/54)
  • [feature] Basic support for touch handling #61
  • [feature] Allow interaction to be toggled on or off #65
  • [feature] Allow controls to be removed on initialization.
  • [internal] Refactor out native DOM and use registered mapbox-gl-js ones.
  • [internal] Remove custom implementation of a geocoder and use mapbox-gl-geocoder.
  • [internal] Use plain XMLHttpRequest for direction queries.

2.0.0

  • [breaking] Drop directions prefix from event names #59
  • [bug] Fix loading UI state and clearing past geocoded results #58
  • [breaking] Update peerDependencies to use mapbox-gl-js@v0.16.0 #56
  • [feature] Zoom to bounds if exist on origin or destination geocode #46
  • [feature] Pass custom styles in options argument #45
  • [bug] Fix points where a geocoded request is not found. Pass coordinates in request #43

1.0.0

  • [bug] Infer container if no element is passed #30
  • [feature] Pass container as an options param #30
  • [breaking] Change proximity option to [lng, lat] format #29
  • [feature] Toggle routes from sidebar listing #28
  • [ui] Target mobile devices with media queries #26
  • [ui] Add loading state to input queries #25
  • [ui] Display routing errors in the instructions panel #24

0.0.0

  • Initial commit