Add support for Mapbox radiuses parameter#396
Add support for Mapbox radiuses parameter#396itbeyond wants to merge 1 commit intoperliedman:masterfrom
Conversation
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.
perliedman
left a comment
There was a problem hiding this comment.
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.
| '&alternatives=' + computeAlternative.toString() + | ||
| '&steps=' + computeInstructions.toString() + | ||
| (this.options.useHints ? '&hints=' + hints.join(';') : '') + | ||
| (this.options.radiuses ? '&radiuses=' + locs.fill(this.options.radiuses).join(';') : '') + |
There was a problem hiding this comment.
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 :)
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.