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

Add support for Mapbox radiuses parameter #396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

itbeyond
Copy link

@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
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.

@@ -347,6 +347,7 @@
'&alternatives=' + computeAlternative.toString() +
'&steps=' + computeInstructions.toString() +
(this.options.useHints ? '&hints=' + hints.join(';') : '') +
(this.options.radiuses ? '&radiuses=' + locs.fill(this.options.radiuses).join(';') : '') +
Copy link
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