Skip to content

Commit fd2e096

Browse files
committed
expose setProfile
1 parent 07ebea2 commit fd2e096

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/directions.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,27 @@ export default class MapboxDirections {
443443
return this;
444444
}
445445

446+
/**
447+
* Sets origin. _Note:_ calling this method requires the [map load event](https://www.mapbox.com/mapbox-gl-js/api/#Map.load)
448+
* to have run.
449+
* @param {Array<number>|String} query An array of coordinates [lng, lat] or location name as a string.
450+
* @returns {MapboxDirections} this
451+
*/
452+
setProfile(query) {
453+
console.log(query);
454+
if (typeof query === 'string') {
455+
if (query === `mapbox/driving-traffic` ||
456+
query === `mapbox/driving` ||
457+
query === `mapbox/walking` ||
458+
query === `mapbox/cycling`) {
459+
this.actions.setProfile(query);
460+
this.actions.eventEmit('profile', { query });
461+
}
462+
}
463+
464+
return this;
465+
}
466+
446467
/**
447468
* Returns the destination of the current route.
448469
* @returns {Object} destination

0 commit comments

Comments
 (0)