Trip
A Trip represents a complete set of turn-by-turn directions between the waypoints passed to Nav.directions. A Trip is composed of one or more TripLeg instances; one leg for each pair of consecutive waypoints.
map.nav().directions(waypoints, function (error, trip) {
if (error) {
return;
}
console.log("Total time (seconds):", trip.time());
console.log("Total distance (feet):", trip.distance());
});Trip.time()
Get the total estimated duration of the Trip, in seconds.
Returns
A Number.
Trip.distance()
Get the total distance of the Trip, in feet.
Returns
A Number.
Trip.leg()
Get the currently displayed TripLeg.
Returns
A new TripLeg instance.
Trip.legs()
Get all of the TripLeg instances which make up the Trip.
// Display the next leg of the trip:
trip.legs().next().show();Returns
A new TripLegSelection instance.
Trip.locations()
Get all of the Location instances representing the Trip's waypoints.
Returns
A new LocationSelection instance.
Trip.bounds([floorId])
Get the bounding box of the Trip, optionally constrained to a single floor.
// Zoom and pan the map to fit the entire trip.
map.fitBounds(trip.bounds(), { padding: 100 });Arguments
| Argument | Required | Type | Default Value | Description |
|---|---|---|---|---|
| floorId | No | String | undefined | The id of a Floor to constrain the bounds to. When omitted, the bounds span the entire Trip. |
Returns
A bounding box as a nested Array of the form [[minX, minY], [maxX, maxY]], suitable for passing to UnitMap.fitBounds.
Updated 1 day ago
