Skip to content

Add support for Mapbox radiuses parameter#396

Open
itbeyond wants to merge 1 commit intoperliedman:masterfrom
itbeyond:master
Open

Add support for Mapbox radiuses parameter#396
itbeyond wants to merge 1 commit intoperliedman:masterfrom
itbeyond:master

Conversation

@itbeyond
Copy link
Copy Markdown

@itbeyond itbeyond commented Mar 3, 2017

To add this during the setup of the L.Routing.mapbox constructor add include the radiuses parameter.
e.g. L.Routing.mapbox(mapbox_token, { radiuses: 3000 })

Mapbox Radiuses - Maximum distance in meters that each coordinate is allowed to move when snapped to a nearby road segment.

Allows the ability to generate an error for an unreachable road segment. rather than creating a straight line.

To add this during the setup of the L.Routing.mapbox constructor add include the radiuses parameter.
e.g. L.Routing.mapbox(mapbox_token, { radiuses: 3000 })

Mapbox Radiuses - Maximum distance in meters that each coordinate is allowed to move when snapped to a nearby road segment.

Allows the ability to generate an error for an unreachable road segment. rather than creating a straight line.
Copy link
Copy Markdown
Owner

@perliedman perliedman left a comment

Choose a reason for hiding this comment

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

Hi and thanks!

I've added a comment about necessary changes to support non-ES6 browsers.

Also, it would be great if you could also pass an array as radiuses, to take full advantage of the API, with different radius for each waypoint. So basically: if radiuses is a single value, use same for all, if it's an array, use separate value for each waypoint.

Comment thread src/osrm-v1.js
'&alternatives=' + computeAlternative.toString() +
'&steps=' + computeInstructions.toString() +
(this.options.useHints ? '&hints=' + hints.join(';') : '') +
(this.options.radiuses ? '&radiuses=' + locs.fill(this.options.radiuses).join(';') : '') +
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Array.prototype.fill is an ES6 method, and not supported in any IE version according to (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/fill); Leaflet Routing Machine still supports quite old IE versions.

Also, note that fill operates in place, overwriting the array - while this works in this case, it's setting up a trap for future modifications.

So, please use something more old school :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants