Я использую Leaflet Routing API, подключенный к Mapbox, для отображения маршрута с несколькими путевыми точками.Теперь я должен извлечь расстояние и время между этими путевыми точками для некоторых вычислений ...
Я вижу, что API api.mapbox.com/directions (вызываемый через Leaflet) получает в результате массив ногмежду моими путевыми точками и всеми необходимыми мне данными ( leg '' расстояние и длительность):
routes: [,…]
0: {legs: [{summary: "A 35, D 415", weight: 4813.6, duration: 4594.8,…},…], weight_name: "routability",…}
distance: 447598.9
duration: 22889.300000000003
legs: [{summary: "A 35, D 415", weight: 4813.6, duration: 4594.8,…},…]
0: {summary: "A 35, D 415", weight: 4813.6, duration: 4594.8,…}
distance: 101906.2
duration: 4594.8
steps: [{intersections: [{out: 0, entry: [true], bearings: [301], location: [7.761832, 48.592052]},…],…},…]
summary: "A 35, D 415"
1: {summary: "D 18bis, D 1bis", weight: 2070.1, duration: 1890.6,…}
distance: 28743.3
duration: 1890.6
steps: [{intersections: [{out: 0, entry: [true], bearings: [310], location: [7.538932, 47.928985]}],…},…]
summary: "D 18bis, D 1bis"
weight: 2070.1
2: {summary: "D 83, N 66", weight: 5097, duration: 4510.1,…}
...
Я ловлю этот результат с событием "routefound", но не получаюноги из набора результатов:
{route: {…}, alternatives: Array(0), type: "routeselected", target: e, sourceTarget: e}
alternatives: []
route:
coordinates: (8188) [M, M, M, M, M, M, M, M, …]
inputWaypoints: (6) [e, e, e, e, e, e]
instructions: (104) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, …]
name: "A 35, D 415, D 18bis, D 1bis, D 83, N 66, Rue du Ballon d'Alsace, D 465, La Comtoise, L'Alsacienne"
properties: {isSimplified: true}
routesIndex: 0
summary:
totalDistance: 447598.9
totalTime: 22889.300000000003
__proto__: Object
waypointIndices: (6) [0, 1611, 2100, 3485, 5808, 8187]
waypoints: (6) [e, e, e, e, e, e]
__proto__: Object
sourceTarget: e {options: {…}, _router: e, _plan: e, _requestCount: 1, _formatter: e, …}
target: e {options: {…}, _router: e, _plan: e, _requestCount: 1, _formatter: e, …}
type: "routeselected"
Есть ли способ получить доступ к собственному результату через Leaflet, или я вынужден сделать двойной вызов API Mapbox, чтобы обойти Leaflet?