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 getDistinctSections

    • Finds the stretches of each route that none of the other routes drives.

      Parameters

      • routes: Routes | Route[]

        The routes to compare, typically a route and its alternatives.

      • options: DistinctSectionsOptions = {}

        The thresholds a section has to reach to be kept.

      Returns DistinctSectionProps[][]

      One array per route, in the order of routes, with its distinct sections in order along it. A single route is distinct end to end.

      calculateRoute already fills sections.distinct with every distinct section when it returns two or more routes. Call this to compare routes from separate calculations, or to keep only the sections worth naming. Routes match on a road where they carry the same coordinates along it, as the routes of one response do; routes from separate calculations may not.

      const routes = await calculateRoute({ locations, maxAlternatives: 2 });
      const longOnes = getDistinctSections(routes, { minLengthInMeters: 1000 });
      longOnes.forEach((sections, routeIndex) => console.log(routeIndex, sections.map((section) => section.lengthInMeters)));