Compatibility with Mapbox Optimization API#534
Compatibility with Mapbox Optimization API#534Bigood wants to merge 3 commits intoperliedman:masterfrom
Conversation
Using the argument routingOptions. A "default" key will result as the parameter not being added at all on the query string, otherwise, if a boolean is provided, it will be appended with the corresponding key.
Mapbox optimization route returns trips instead of routes
|
Hi. Any updates on this? have the same mistake and don't want to change source code. What do I do? |
|
Yeah - same here. I'd like to get some cycle routes onto the maps .... |
|
@perliedman It's been a year since I've PR this, any plan to merge it? |
| route = this._convertRoute(response.routes[i]); | ||
| //Mapbox optimization route returns trips instead of routes | ||
| let routes = response.routes || response.trips; | ||
| for (i = 0; i < routes.length; i++) { |
There was a problem hiding this comment.
Looks like some indentation mistake here, perhaps spaces/tabs getting mixed up?
| latLng, | ||
| computeInstructions, | ||
| computeAlternative = true; | ||
| computeInstructions = options.steps && options.steps !== "default" ? true : false, |
There was a problem hiding this comment.
What does this new "default" mean? How is it intended to be used?
|
@Bigood yeah sorry about that, I don't use LRM for anything myself these days, so it's hard to find the time/energy to work on it, and easy to miss issues and PRs. This looks good as far as I can tell, with some minor comments I made to the code. Haven't actually tested the code, but I assume you have tested it still works with "normal" routing as well as with the optimization API? |
|
Thanks for taking the time to review this! I'll test it again with the most recent API, double check my code, and probably correct some bits. |
Original issue
Passing
alternative=(true|false)to the Mapbox Optimization API resulted as a bad request, I needed to have the option to remove the query parameter. While looking at the code, I changed a few things to be able to remove steps and pass the roundtrip parameter to the API.Reference : https://docs.mapbox.com/api/navigation/#optimization
Usecase
Changes
Mainly on osrm-v1.js, to be compatible Mapbox Optimization API, see attached commits.