Skip to content

Commit

Permalink
update test so it can return a valid route, fix instructions display
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed Feb 1, 2017
1 parent 0a9a561 commit aab992e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ function fetchDirections() {
// Request params
var options = [];
options.push('geometries=polyline');
options.push('steps=true');
options.push('alternatives=true');
options.push('steps=true');
options.push('overview=full');
options.push('access_token=' + accessToken);

request.abort();
request.open('GET', `${api}mapbox/${profile}/${query}.json?${options.join('&')}`, true);

Expand All @@ -81,7 +79,7 @@ function fetchDirections() {

// Revise origin / destination points
dispatch(originPoint(data.waypoints[0].location));
dispatch(destinationPoint(data.waypoints[res.waypoints.length - 1].location));
dispatch(destinationPoint(data.waypoints[data.waypoints.length - 1].location));
} else {
dispatch(setDirections([]));
return dispatch(setError(JSON.parse(request.responseText).message));
Expand Down
2 changes: 1 addition & 1 deletion src/controls/instructions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Instructions {
this.container.innerHTML = instructionsTemplate({
routeIndex,
routes: directions.length,
steps: directions.legs[0].steps, // Todo: Respect all legs,
steps: direction.legs[0].steps, // Todo: Respect all legs,
format: utils.format[unit],
duration: utils.format[unit](direction.distance),
distance: utils.format.duration(direction.duration)
Expand Down
3 changes: 1 addition & 2 deletions src/directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ export default class MapboxDirections {
};

geojson.features.push(lineString);

if (index === routeIndex) {
// Collect any possible waypoints from steps
feature.steps.forEach((d) => {
feature.legs[0].steps.forEach((d) => {
if (d.maneuver.type === 'waypoint') {
geojson.features.push({
type: 'Feature',
Expand Down
2 changes: 1 addition & 1 deletion test/test.directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test('directions', (tt) => {
}
});

directions.setOrigin('Queen Street');
directions.setOrigin('Queen Street NY');
directions.setDestination([-77, 41]);

directions.on('origin', function(e) {
Expand Down

0 comments on commit aab992e

Please sign in to comment.