SegmentSelection
A collection of zero or more floor segments of a TripLeg, returned by the segments() method on a leg. A segment groups the Maneuver instances which occur on a single Floor.
map.nav().directions(waypoints, function (error, trip) {
var segments = trip.leg().segments();
// Fit the map to the first segment:
map.fitBounds(segments.at(0).bounds(), { padding: 100 });
});SegmentSelection.length
The number of segments in the collection.
SegmentSelection.at(index)
Get the segment at the given index.
Arguments
| Argument | Required | Type | Default Value | Description |
|---|---|---|---|---|
| index | Yes | Integer | undefined | The index of the desired segment. |
Returns
A new SegmentSelection instance.
SegmentSelection.find(maneuverId)
Get the segment containing the Maneuver with the given id.
Arguments
| Argument | Required | Type | Default Value | Description |
|---|---|---|---|---|
| maneuverId | Yes | String | undefined | The id of a maneuver contained by the desired segment. |
Returns
A new SegmentSelection instance.
SegmentSelection.floorId()
Get the id of the Floor the first segment in the collection is located on.
Returns
A String, or null if the collection is empty.
SegmentSelection.startIndex()
Get the index of the first maneuver of the first segment within its leg.
Returns
A Number, or null if the collection is empty.
SegmentSelection.endIndex()
Get the index of the last maneuver of the first segment within its leg.
Returns
A Number, or null if the collection is empty.
SegmentSelection.bounds()
Get the combined bounding box of the segments in the collection.
// Zoom and pan the map to fit every segment in the collection.
map.fitBounds(segments.bounds(), { padding: 100 });Returns
A bounding box as a nested Array of the form [[minX, minY], [maxX, maxY]], suitable for passing to UnitMap.fitBounds, or null if the collection is empty.
SegmentSelection.maneuvers()
Get a selection of the Maneuver instances contained by the segments in the collection.
Returns
A new ManeuverSelection instance.
SegmentSelection.each(iterator)
Iterate over each segment in the collection. This method is chainable.
Arguments
| Argument | Required | Type | Default Value | Description |
|---|---|---|---|---|
| iterator | Yes | Function | undefined | A function invoked with each segment (as a single-item SegmentSelection). |
Returns
The object chain.
SegmentSelection.map(iterator)
Map over each segment in the collection, returning an array of the iterator results.
Arguments
| Argument | Required | Type | Default Value | Description |
|---|---|---|---|---|
| iterator | Yes | Function | undefined | A function invoked with each segment (as a single-item SegmentSelection). |
Returns
An Array of the iterator return values.
Updated 1 day ago
