Route Leg Options Playground
Give each leg of a calculated route its own route type and avoid list, and recalculate on every change.
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
legCostModelrides on the properties of the stop a leg arrives at, so the options travel with the stops rather than in a parallel array. calculateRoutereplans on every change, andsections.legcomes back on the route, so each leg’s summary is read off the response.formatDistanceandformatDurationturn those metres and seconds into the labels shown.- Point at a leg in the panel and
setSectionFocusrings it on the map, so you see which stretch of road each set of options shapes.
Related examples
Add Stops to Route (Playground)
Dynamically add and remove intermediate stops on a route by clicking the map
Playground
Routing
Utilities
User Interaction Events
Web
Along route search playground
Search along one of several drives by query or category, or only along chosen section types or a share of its length
Playground
Routing
Search and Geocoding
Web
Map Chat Agent
Ask a chat beside the map for places, routes or traffic, and watch the map search, draw and frame the answer
Playground
AI
Search and Geocoding
Places and POIs
Map Style
Base Map
Geometry
Traffic
Routing
Plugins
Web
React
Map Chat Agent State Playground
A map chat whose every result lands in a side panel, where you can show, hide or drop it yourself
Playground
AI
Search and Geocoding
Places and POIs
Map Style
Base Map
Geometry
Traffic
Routing
Bring Your Own Data
Plugins
Web
React