Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new OSRM API #1261

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/assets/javascripts/index/directions/osrm.js
Expand Up @@ -82,6 +82,8 @@ function OSRMEngine() {
break;
case 'roundabout turn':
case 'turn':
maneuver_id = "turn " + step.maneuver.modifier;
break;
// for unknown types the fallback is turn
default:
maneuver_id = "turn " + step.maneuver.modifier;
Expand All @@ -91,7 +93,7 @@ function OSRMEngine() {

var segment_end_point = line.length;
// convert lat,lng pairs to LatLng objects
var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map((a) => { return L.latLng(a); }) ;
var step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 }).map(function(a) { return L.latLng(a); }) ;
// append step_geometry on line
Array.prototype.push.apply(line, step_geometry);

Expand All @@ -118,14 +120,14 @@ function OSRMEngine() {


if (cachedHints.length == points.length) {
params.push({name: "hints", value: cachedHints.join(";")})
params.push({name: "hints", value: cachedHints.join(";")});
} else {
// invalidate cache
cachedHints = [];
}

var encoded_coords = points.map(function(p) {
return p.lng + ',' + p.lat
return p.lng + ',' + p.lat;
}).join(';');

var req_url = document.location.protocol + OSM.OSRM_URL + encoded_coords;
Expand Down