leaflet-routing-machine
leaflet-routing-machine copied to clipboard
Support OSRM's trip API
As suggested in https://github.com/perliedman/leaflet-routing-machine/issues/203#issuecomment-177430492.
:100: :+1:
So, with this api support will it show all possible trips as mentioned in the osrm project ?
Trip service
The trip plugin solves the Traveling Salesman Problem using a greedy heuristic (farthest-insertion algorithm). The returned path does not have to be the fastest path, as TSP is NP-hard it is only an approximation. Note that if the input coordinates can not be joined by a single trip (e.g. the coordinates are on several disconnected islands) multiple trips for each connected component are returned.
There's no clear plan at this point. It's only a suggested feature.
Help getting this done, in the form of a PR, or sponsorship for developing it would be welcome.
hello, i have set up osrm demo server. and i already have the respond json from match service,so,how could i use the lrm draw this ponits in demo web,
As far as I can tell, the trip service has a response format identical to route, except that each Waypoint object in waypoints has a trips_index property, and the routes property is called trips instead (but still holds Route objects). The request options are similar too. So I suspect this is just a matter of falling back to response.trips if there’s no response.routes:
https://github.com/perliedman/leaflet-routing-machine/blob/04e899ea765cadae033d941e9de13846540ce69b/src/osrm-v1.js#L161-L162