perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

is the plugin compatible with mapbox optimization api? #561

Open novaknole opened 4 years ago

novaknole commented 4 years ago

Hi .

I am using this plugin. Other than routing which I use Directions API router, it works fine, but I also want to use Optimization API, so I changed serviceurl and added profile. The error that happens is that in the query parameter, there's a alternatives parameter all the time, doesn't matter what I pass in which causes mapbox to return 422 error (query parameters wrong).

I looked through the code and here is what's written:

return this.options.serviceUrl + '/' + this.options.profile + '/' +
                locs.join(';') + '?' +
                (options.geometryOnly ? (options.simplifyGeometry ? '' : 'overview=full') : 'overview=false') +
                '&alternatives=' + computeAlternative.toString() +
                '&steps=' + computeInstructions.toString() +
                (this.options.useHints ? '&hints=' + hints.join(';') : '') +
                (options.allowUTurns ? '&continue_straight=' + !options.allowUTurns : '');

So alternatives is always true. how do I fix it or will i even be able to use this plugin for optimization api? Same thing was asked here: https://github.com/perliedman/leaflet-routing-machine/pull/534