require(["esri/rest/support/TravelMode"], (TravelMode) => { /* code goes here */ });
import TravelMode from "@arcgis/core/rest/support/TravelMode.js";
esri/rest/support/TravelMode
A TravelMode is a set of characteristics that define how an object like a vehicle, bicycle, or pedestrian moves along a street network. Those characteristics are considered when finding directions to determine how the vehicle or pedestrian travels, and where they can go. To get a list of supported travel modes, find the default travel mode, and to find and use a specific travel mode, you can use the networkService.fetchServiceDescription() method:
// 1. Get the default and supported travel modes of a route service
const apiKey = "<your api key>";
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
const serviceDescription = await fetchServiceDescription(url, apiKey);
const { defaultTravelMode, supportedTravelModes } = serviceDescription;
console.log(`The name of the default travel mode is: ${defaultTravelMode.name}.`);
console.log(`This service has ${supportedTravelModes.length} preset travel modes`);
// 2. Find and use the "Driving Time" travel mode
const apiKey = "<your api key>";
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
const serviceDescription = await fetchServiceDescription(url, apiKey);
const { supportedTravelModes } = serviceDescription;
const driveTimeTravelMode = supportedTravelModes.find(({ name }) => name === "Driving Time");
// Solve a route using the "Driving Time" travel mode
const routeParameters = {
stops: stopsFeatureSet, // route stops
travelMode: driveTimeTravelMode
};
const result = await solve(url, routeParameters);
For ArcGIS Enterprise services, the default value for a travel mode is based on the layer setting when the map service is published with the network analysis capabilities. Open the service description page to see the default values for the parameters.
- See also
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
Lists the parameterized attributes used by the travel mode. | TravelMode | ||
The name of the class. | Accessor | ||
A short text description of the travel mode. | TravelMode | ||
Indicates the distance-based cost attribute for reporting directions and for solving vehicle routing problems. | TravelMode | ||
The unique identifier. | TravelMode | ||
The network cost attribute used as impedance. | TravelMode | ||
The unique name of the travel mode. | TravelMode | ||
The list of the restriction attributes used when solving network analysis problems with this travel mode. | TravelMode | ||
Specifies whether the travel mode generalizes the geometry of analysis results and by how much. | TravelMode | ||
The linear units associated with simplificationTolerance. | TravelMode | ||
Indicates the time-based cost attribute for reporting directions. | TravelMode | ||
Indicates the category of travel or vehicle represented by this travel mode. | TravelMode | ||
Indicates whether the travel mode uses a hierarchy attribute while performing the analysis. | TravelMode | ||
Indicates how the U-turns at junctions that could occur during network traversal are handled by the solver. | TravelMode |
Property Details
-
Lists the parameterized attributes used by the travel mode.
-
description
description String
-
A short text description of the travel mode.
-
distanceAttributeName
distanceAttributeName String
-
Indicates the distance-based cost attribute for reporting directions and for solving vehicle routing problems.
Possible Values:"kilometers" |"miles" |"meters"
-
id
id String
-
The unique identifier.
-
impedanceAttributeName
impedanceAttributeName String
-
The network cost attribute used as impedance. This cost attribute is minimized while solving network analysis problems.
Possible Values:"kilometers" |"miles" |"meters" |"minutes" |"travel-time" |"truck-minutes" |"truck-travel-time" |"walk-time"
-
name
name String
-
The unique name of the travel mode.
-
The list of the restriction attributes used when solving network analysis problems with this travel mode.
Possible Values:"any-hazmat-prohibited" |"avoid-carpool-roads" |"avoid-express-lanes" |"avoid-ferries" |"avoid-gates" |"avoid-limited-access-roads" |"avoid-private-roads" |"avoid-roads-unsuitable-for-pedestrians" |"avoid-stairways" |"avoid-toll-roads" |"avoid-toll-roads-for-trucks" |"avoid-truck-restricted-roads" |"avoid-unpaved-roads" |"axle-count-restriction" |"driving-a-bus" |"driving-a-taxi" |"driving-a-truck" |"driving-an-automobile" |"driving-an-emergency-vehicle" |"height-restriction" |"kingpin-to-rear-axle-length-restriction" |"length-restriction" |"preferred-for-pedestrians" |"riding-a-motorcycle" |"roads-under-construction-prohibited" |"semi-or-tractor-with-one-or-more-trailers-prohibited" |"single-axle-vehicles-prohibited" |"tandem-axle-vehicles-prohibited" |"through-traffic-prohibited" |"truck-with-trailers-restriction" |"use-preferred-hazmat-routes" |"use-preferred-truck-routes" |"walking" |"weight-restriction" |"string"
-
simplificationTolerance
simplificationTolerance Number
-
Specifies whether the travel mode generalizes the geometry of analysis results and by how much.
-
simplificationToleranceUnits
simplificationToleranceUnits String
-
The linear units associated with simplificationTolerance.
Possible Values:"centimeters" |"decimal-degrees" |"decimeters" |"feet" |"inches" |"kilometers" |"meters" |"miles" |"millimeters" |"nautical-miles" |"points" |"unknown" |"yards"
-
timeAttributeName
timeAttributeName String
-
Indicates the time-based cost attribute for reporting directions.
Possible Values:"minutes" |"travel-time" |"truck-minutes" |"truck-travel-time" |"walk-time"
-
type
type String
-
Indicates the category of travel or vehicle represented by this travel mode.
Possible Values:"automobile" |"truck" |"walk" |"other"
-
useHierarchy
useHierarchy Boolean
-
Indicates whether the travel mode uses a hierarchy attribute while performing the analysis.
-
uturnAtJunctions
uturnAtJunctions String
-
Indicates how the U-turns at junctions that could occur during network traversal are handled by the solver.
Possible Values:"allow-backtrack" |"at-dead-ends-only" |"no-backtrack" |"at-dead-ends-and-intersections"
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
this | Creates a deep clone of this object. | TravelMode | |
* | Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. | TravelMode | |
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor | ||
Converts an instance of this class to its ArcGIS portal JSON representation. | TravelMode |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.
ReturnsType Description this A deep clone of the class instance that invoked this method.
-
Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input
json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.Parameterjson ObjectA JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.
ReturnsType Description * Returns a new instance of this class.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
toJSON
toJSON(){Object}
-
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
ReturnsType Description Object The ArcGIS portal JSON representation of an instance of this class.