leaflet-routing-machine
leaflet-routing-machine copied to clipboard
Compatibility with Mapbox Optimization API
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
router: L.Routing.mapbox(process.env.REACT_APP_MAPBOX_API_KEY, {
serviceUrl: 'https://api.mapbox.com/optimized-trips/v1', //Overrides the serviceUrl
profile : 'mapbox/cycling',
routingOptions: {
roundtrip:true, //Wasn't used on the url construction
steps: false, //Will be considered as an option
alternatives: "default" //Will remove the appended option on the URL
}
}),
Changes
Mainly on osrm-v1.js, to be compatible Mapbox Optimization API, see attached commits.
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?
@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.