This is the documentation of version 1.0.0-rc.4. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Function getInstructionLanes

    • Finds the lanes section leading to an instruction's maneuver.

      Parameters

      • route: Route

        The route the instruction belongs to.

      • instruction: Pick<Instruction, "pathPointIndex" | "maneuver">

        One of the route's guidance.instructions.

      Returns LaneSectionProps | undefined

      The lane section, or undefined when the route has none leading to the maneuver.

      calculateRoute returns lanes sections only with guidance, and not every maneuver has one.

      A section leads to the last instruction inside it or, when it ends at a stop line short of the junction, to the next one after it. Where several lead to one instruction, the closest wins. Instructions sharing a point, such as a roundabout's entry and exit, leave the lanes to the first.

      const routes = await calculateRoute({ locations, guidance: { type: 'coded' } });
      const route = routes.features[0];
      for (const instruction of route.properties.guidance?.instructions ?? []) {
      const lanes = getInstructionLanes(route, instruction);
      // lanes?.lanes: each lane's directions, and the one to follow
      }