This is the documentation of version 1.0.0-rc.4. Go to the latest version, 1.0.0-rc.5.

Routes

A route (Route) is a GeoJSON Feature whose LineString geometry is the path. Its properties carry the summary, sections, guidance and progress. calculateRoute returns Routes, a FeatureCollection of the main route and its alternatives.

Where routes are used

Route object structure

Summary

route.properties.summary:

trafficDelayInSeconds is the delay of the traffic events along trafficLengthInMeters. For the gap to free-flow, use Math.max(0, liveTrafficIncidentsTravelTimeInSeconds - noTrafficTravelTimeInSeconds). The live travel time can fall below the free-flow one, so keep the floor at 0.

const { liveTrafficIncidentsTravelTimeInSeconds: live, noTrafficTravelTimeInSeconds: freeFlow } =
    route.properties.summary;
const delayInSeconds = live !== undefined && freeFlow !== undefined ? Math.max(0, live - freeFlow) : undefined;

Sections

route.properties.sections groups the stretches of a route by type. Each section spans a range of indices into the route's coordinates. sectionTypes sets which types a calculation returns. A requested type appears only where the route has such a stretch (no ferry without a water crossing). The routing module draws them.

Section types

Section properties

Every section has id, startPointIndex and endPointIndex (inclusive). These types have more:

Progress

Unless the calculation passed extendedRouteRepresentations: [], route.properties.progress gives the cumulative distance and time at points along the path.

The progress utilities interpolate between these points.

Guidance

If you request guidance, each of route.properties.guidance.instructions has:

API reference

Route

Related guides and examples

Related guides

Map integration

Related examples