Route Leg Options Playground

Give each leg of a calculated route its own route type and avoid list, and recalculate on every change.

View on GitHub
SDK 1.0.0-rc.7

Each leg of a four-stop route carries its own route type and avoid list, and reports its own distance, driving time and waiting time.

  • A legCostModel rides on the properties of the stop a leg arrives at, so the options travel with the stops rather than in a parallel array.
  • calculateRoute replans on every change, and sections.leg comes back on the route, so each leg’s summary is read off the response.
  • formatDistance and formatDuration turn those metres and seconds into the labels shown.
  • Point at a leg in the panel and setSectionFocus rings it on the map, so you see which stretch of road each set of options shapes.

Related examples