TravelMode

AMD: require(["esri/rest/support/TravelMode"], (TravelMode) => { /* code goes here */ });
ESM: import TravelMode from "@arcgis/core/rest/support/TravelMode";
Class: esri/rest/support/TravelMode
Inheritance: TravelMode Accessor
Since: ArcGIS API for JavaScript 4.20

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 id of the default travel mode is: ${defaultTravelMode}.`);
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((mode) => mode.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

new TravelMode(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Object[]more details

Lists the parameterized attributes used by the travel mode.

more detailsTravelMode
Stringmore details

The name of the class.

more detailsAccessor
Stringmore details

A short text description of the travel mode.

more detailsTravelMode
Stringmore details

Indicates the distance-based cost attribute for reporting directions and for solving vehicle routing problems.

more detailsTravelMode
Stringmore details

The unique identifier.

more detailsTravelMode
Stringmore details

The network cost attribute used as impedance.

more detailsTravelMode
Stringmore details

The unique name of the travel mode.

more detailsTravelMode
String[]more details

The list of the restriction attributes used when solving network analysis problems with this travel mode.

more detailsTravelMode
Numbermore details

Specifies whether the travel mode generalizes the geometry of analysis results and by how much.

more detailsTravelMode
Stringmore details

The linear units associated with simplificationTolerance.

more detailsTravelMode
Stringmore details

Indicates the time-based cost attribute for reporting directions.

more detailsTravelMode
Stringmore details

Indicates the category of travel or vehicle represented by this travel mode.

more detailsTravelMode
Booleanmore details

Indicates whether the travel mode uses a hierarchy attribute while performing the analysis.

more detailsTravelMode
Stringmore details

Indicates how the U-turns at junctions that could occur during network traversal are handled by the solver.

more detailsTravelMode

Property Details

attributeParameterValues Object[]

Lists the parameterized attributes used by the travel mode.

Properties:
attributeName String

The name of the attribute.

parameterName String

The parameter name.

value String

The parameter value.

declaredClass Stringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

description String

A short text description of the travel mode.

distanceAttributeName String

Indicates the distance-based cost attribute for reporting directions and for solving vehicle routing problems.

id String

The unique identifier.

impedanceAttributeName String

The network cost attribute used as impedance. This cost attribute is minimized while solving network analysis problems.

name String

The unique name of the travel mode.

restrictionAttributeNames String[]

The list of the restriction attributes used when solving network analysis problems with this travel mode.

simplificationTolerance Number

Specifies whether the travel mode generalizes the geometry of analysis results and by how much.

simplificationToleranceUnits String

The linear units associated with simplificationTolerance.

Possible Values:"centimeters"|"decimal-degrees"|"decimeters"|"feet"|"inches"|"kilometers"|"meters"|"miles"|"millimeters"|"nautical-miles"|"points"|"yards"

timeAttributeName String

Indicates the time-based cost attribute for reporting directions.

type String

Indicates the category of travel or vehicle represented by this travel mode.

Possible Values:"automobile"|"truck"|"walk"|"other"

useHierarchy Boolean

Indicates whether the travel mode uses a hierarchy attribute while performing the analysis.

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
TravelModemore details

Returns a deep clone of the travel mode object.

more detailsTravelMode
*more details

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

more detailsTravelMode
Objectmore details

Converts an instance of this class to its ArcGIS portal JSON representation.

more detailsTravelMode

Method Details

clone(){TravelMode}

Returns a deep clone of the travel mode object.

Returns:
Type Description
TravelMode Returns a deep clone of the travel mode object.
fromJSON(json){*}static

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.

Parameter:
json Object

A 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.

Returns:
Type Description
* Returns a new instance of this class.
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns:
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.