Skip to content

Commit 2ac2d23

Browse files
committed
Toggle or disable profile switcher.
1 parent e76955f commit 2ac2d23

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/controls/inputs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ let tmpl = template(fs.readFileSync(__dirname + '/../templates/inputs.html', 'ut
1717
*/
1818
export default class Inputs {
1919
constructor(el, store, actions, map) {
20-
const { originQuery, destinationQuery, profile } = store.getState();
20+
const { originQuery, destinationQuery, profile, profileSwitcher } = store.getState();
2121

2222
el.innerHTML = tmpl({
2323
originQuery,
2424
destinationQuery,
25-
profile
25+
profile,
26+
profileSwitcher
2627
});
2728

2829
this.container = el;

src/directions.js

Lines changed: 1 addition & 0 deletions
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="mapbox/driving-traffic"] Routing profile to use. Options: `mapbox/driving-traffic`, `mapbox/driving`, `mapbox/walking`, `mapbox/cycling`
27+
* @param {Boolean} [options.profileSwitcher=true] Whether to show the default profile switch with options for traffic, driving, walking and cycling.
2728
* @param {Boolean} [options.alternatives=true] Whether to enable alternatives.
2829
* @param {String} [options.unit="imperial"] Measurement system to be used in navigation instructions. Options: `imperial`, `metric`
2930
* @param {Function} [options.compile=null] Provide a custom function for generating instruction, compatible with osrm-text-instructions.

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: 'mapbox/driving-traffic',
8+
profileSwitcher: true,
89
alternatives: false,
910
unit: 'imperial',
1011
compile: null,

src/templates/inputs.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</div>
2121
</div>
2222

23+
<% if (profileSwitcher) { %>
2324
<div class='mapbox-directions-profile mapbox-directions-component-keyline mapbox-directions-clearfix'><input
2425
id='mapbox-directions-profile-driving-traffic'
2526
type='radio'
@@ -53,4 +54,5 @@
5354
/>
5455
<label for='mapbox-directions-profile-cycling'>Cycling</label>
5556
</div>
57+
<% } %>
5658
</div>

0 commit comments

Comments
 (0)