TripLeg

A TripLeg represents the portion of a Trip between two consecutive waypoints. A leg is made up of one or more floor segments, each containing a series of Maneuver instances.

map.nav().directions(waypoints, function (error, trip) {
  var leg = trip.leg();

  console.log("Leg", leg.index(), "takes", leg.time(), "seconds");
});

TripLeg.id

The unique identifier of the TripLeg.

TripLeg.index()

Get the zero-based index of the leg within the Trip.

Returns

A Number.

TripLeg.time()

Get the estimated duration of the leg, in seconds.

Returns

A Number.

TripLeg.distance()

Get the distance of the leg, in feet.

Returns

A Number.

TripLeg.maneuvers()

Get a selection of the Maneuver instances which make up the leg.

Returns

A new ManeuverSelection instance.

TripLeg.segments()

Get a selection of the floor segments which make up the leg. Each segment groups contiguous maneuvers which occur on a single floor.

Returns

A new SegmentSelection instance.

TripLeg.show()

Display the leg, making it the active leg of the Trip . This method is chainable.

Returns

The object chain.

TripLeg.bounds([floorId])

Get the bounding box of the leg, optionally constrained to a single floor.

// Zoom and pan the map to fit the leg.

map.fitBounds(leg.bounds(), { padding: 100 });

Arguments

ArgumentRequiredTypeDefault ValueDescription
floorIdNoStringundefinedThe id of a Floor to constrain the bounds to. When omitted, the bounds span the entire leg.

Returns

A bounding box as a nested Array of the form [[minX, minY], [maxX, maxY]].