Skip to content

Commit c7d8449

Browse files
authored
Merge pull request #139 from mapbox/profile-switcher
Toggle or disable profile switcher.
2 parents e76955f + 5e182b7 commit c7d8449

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, controls } = store.getState();
2121

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

2829
this.container = el;

src/directions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Instructions from './controls/instructions';
3131
* @param {Object} [options.controls]
3232
* @param {Boolean} [options.controls.inputs=true] Hide or display the inputs control.
3333
* @param {Boolean} [options.controls.instructions=true] Hide or display the instructions control.
34+
* @param {Boolean} [options.controls.profileSwitcher=true] Hide or display the default profile switch with options for traffic, driving, walking and cycling.
3435
* @example
3536
* var MapboxDirections = require('../src/index');
3637
* var directions = new MapboxDirections({

src/reducers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const initialState = {
1313

1414
// UI controls
1515
controls: {
16+
profileSwitcher: true,
1617
inputs: true,
1718
instructions: true
1819
},

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 (controls.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)