Skip to content

Commit

Permalink
Adds language parameter (#222)
Browse files Browse the repository at this point in the history
* Update directions.js

* Update index.js

* adds language parameter

* fixes version number

* 4.0.2

* updates changelog
  • Loading branch information
geografa authored Jul 15, 2019
1 parent c097945 commit 236871f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.0.2
- Adds language parameter to allow turn-by-turn instructions in other [supported languages](https://docs.mapbox.com/api/navigation/#instructions-languages)

## 4.0.1
- Update packages to resolve polyline dependency
- Update peerDependency for Mapbox-GL-JS to support v1.0 release
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapbox/mapbox-gl-directions",
"version": "4.0.1",
"version": "4.0.2",
"description": "A mapboxgl plugin for the Mapbox Directions API",
"main": "./src/index.js",
"browserify": {
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 } = getState();
const { api, accessToken, routeIndex, profile, alternatives, congestion, destination, language } = getState();
// if there is no destination set, do not make request because it will fail
if (!(destination && destination.geometry)) return;

Expand All @@ -65,6 +65,7 @@ function fetchDirections() {
if (congestion) options.push('annotations=congestion');
options.push('steps=true');
options.push('overview=full');
if (language) options.push('language='+language);
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 @@ -35,6 +35,7 @@ import Instructions from './controls/instructions';
* @param {Boolean} [options.controls.instructions=true] Hide or display the instructions control.
* @param {Boolean} [options.controls.profileSwitcher=true] Hide or display the default profile switch with options for traffic, driving, walking and cycling.
* @param {Number} [options.zoom=16] If no bbox exists from the geocoder result, the zoom you set here will be used in the flyTo.
* @param {String} [options.language="en"] The language of returned turn-by-turn text instructions. See supported languages : https://docs.mapbox.com/api/navigation/#instructions-languages
* @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.
Expand Down
1 change: 1 addition & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const initialState = {
placeholderOrigin: 'Choose a starting place',
placeholderDestination: 'Choose destination',
zoom: 16,
language: 'en',
compile: null,
proximity: false,
styles: [],
Expand Down

1 comment on commit 236871f

@gerben-van-eck
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know if this is relevant for this project/scope, but I noticed that this breaks compatibility with osrm-routed.

With this option on:
{message: "Query string malformed close to position 1001", code: "InvalidQuery"} code: "InvalidQuery" message: "Query string malformed close to position 1001"

When I set the value to false, it works again.

Please sign in to comment.