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 getSectionBBox

    • Calculates the bounding box for a route section.

      It samples the section's coordinates at three points:

      • The start point, at startPointIndex.
      • The middle point, halfway between start and end.
      • The end point, at endPointIndex.

      Parameters

      • route: Route

        The route containing the section.

      • section: RouteSpan

        The section, or any RouteSpan, to calculate the bbox for.

      Returns OptionalBBox

      The bounding box as [west, south, east, north], or undefined if the section or route is invalid.

      • Three points are fast, but a winding section can stray outside their box. For a tighter box, pass the section's slice of coordinates as a LineString to bboxFromGeoJSON.
      • It returns undefined if the route has no coordinates or the section indices are invalid.
      const section = route.properties.sections.country[0];
      // section = { id: 'section-1', startPointIndex: 0, endPointIndex: 3, countryCodeISO3: 'NLD' }

      const bbox = getSectionBBox(route, section);
      // Returns: [west, south, east, north] spanning the section, or undefined