Skip to main content

Route Instructions

|

Learn how to retrieve and display turn-by-turn navigation instructions for a calculated route.

Live Demo

Code Implementation

index.ts
import {
Route,
RouteSegment,
RouteInstruction
} from '@magiclane/maps-sdk';

function getInstructionsFromSegments(segments: RouteSegment[]): RouteInstruction[] {
const instructionsList: RouteInstruction[] = [];

for (const segment of segments) {
const segmentInstructions = segment.instructions;
instructionsList.push(...segmentInstructions);
}

return instructionsList;
}