Skip to content

Commit

Permalink
#232 - added exclude parameter (#233)
Browse files Browse the repository at this point in the history
* #232 - added `exclude` parameter

* #232 - added `exclude` parameter description in docs
  • Loading branch information
bbantsadze authored and tristen committed Dec 30, 2019
1 parent 236871f commit fa756a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The Directions control
- `options.placeholderOrigin` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** If set, this text will appear as the placeholder attribute for the origin input element. (optional, default `"Choose a starting place"`)
- `options.placeholderDestination` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** If set, this text will appear as the placeholder attribute for the destination input element. (optional, default `"Choose destination"`)
- `options.flyTo` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If false, animating the map to a selected result is disabled. (optional, default `true`)
- `options.exclude` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Exclude certain road types from routing. The default is to not exclude anything. Options: `ferry`, `toll`, `motorway` (optional, default `null`)

**Examples**

Expand Down
3 changes: 2 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function setHoverMarker(feature) {

function fetchDirections() {
return (dispatch, getState) => {
const { api, accessToken, routeIndex, profile, alternatives, congestion, destination, language } = getState();
const { api, accessToken, routeIndex, profile, alternatives, congestion, destination, language, exclude } = getState();
// if there is no destination set, do not make request because it will fail
if (!(destination && destination.geometry)) return;

Expand All @@ -66,6 +66,7 @@ function fetchDirections() {
options.push('steps=true');
options.push('overview=full');
if (language) options.push('language='+language);
if (exclude) options.push('exclude=' + exclude);
if (accessToken) options.push('access_token=' + accessToken);
request.abort();
request.open('GET', `${api}${profile}/${query}.json?${options.join('&')}`, true);
Expand Down
1 change: 1 addition & 0 deletions src/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import Instructions from './controls/instructions';
* @param {String} [options.placeholderOrigin="Choose a starting place"] If set, this text will appear as the placeholder attribute for the origin input element.
* @param {String} [options.placeholderDestination="Choose destination"] If set, this text will appear as the placeholder attribute for the destination input element.
* @param {Boolean} [options.flyTo=true] If false, animating the map to a selected result is disabled.
* @param {String} [options.exclude=null] Exclude certain road types from routing. The default is to not exclude anything. Search for `exclude` in `optional parameters`: https://docs.mapbox.com/api/navigation/#retrieve-directions
* @example
* var MapboxDirections = require('../src/index');
* var directions = new MapboxDirections({
Expand Down

0 comments on commit fa756a1

Please sign in to comment.