Skip to content

Commit 2b6fe1b

Browse files
committed
Disable alternatives by default.
1 parent 46cd036 commit 2b6fe1b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/actions/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ function setHoverMarker(feature) {
5252

5353
function fetchDirections() {
5454
return (dispatch, getState) => {
55-
const { api, accessToken, routeIndex, profile } = getState();
55+
const { api, accessToken, routeIndex, profile, alternatives } = getState();
5656
const query = buildDirectionsQuery(getState);
5757

5858
// Request params
5959
var options = [];
6060
options.push('geometries=polyline');
61-
options.push('alternatives=true');
61+
if (alternatives) options.push('alternatives=true');
6262
options.push('steps=true');
6363
options.push('overview=full');
6464
options.push('access_token=' + accessToken);

src/directions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Instructions from './controls/instructions';
2424
* @param {String} [options.accessToken=null] Required unless `mapboxgl.accessToken` is set globally
2525
* @param {Boolean} [options.interactive=true] Enable/Disable mouse or touch interactivity from the plugin
2626
* @param {String} [options.profile="driving-traffic"] Routing profile to use. Options: `driving-traffic`, `driving`, `walking`, `cycling`
27+
* @param {Boolean} [options.alternatives=true] Whether to enable alternatives.
2728
* @param {String} [options.unit="imperial"] Measurement system to be used in navigation instructions. Options: `imperial`, `metric`
2829
* @param {Object} [options.geocoder] Pass options available to mapbox-gl-geocoder as [documented here](https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md#mapboxglgeocoder).
2930
* @param {Object} [options.controls]
@@ -109,7 +110,7 @@ export default class MapboxDirections {
109110
}
110111

111112
mapState() {
112-
const { profile, styles, interactive } = store.getState();
113+
const { profile, alternatives, styles, interactive } = store.getState();
113114

114115
// Emit any default or option set config
115116
this.actions.eventEmit('profile', { profile });

src/reducers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const initialState = {
55
// Options set on initialization
66
api: 'https://api.mapbox.com/directions/v5/',
77
profile: 'driving-traffic',
8+
alternatives: false,
89
unit: 'imperial',
910
proximity: false,
1011
styles: [],

0 commit comments

Comments
 (0)