require(["esri/rest/support/RouteParameters"], (RouteParameters) => { /* code goes here */ });
import RouteParameters from "@arcgis/core/rest/support/RouteParameters.js";
esri/rest/support/RouteParameters
Input parameters for route. Specifies details such as stop locations, barrier locations, the impedance attribute, etc.
- 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 |
---|---|---|---|
Use this property to specify whether the operation should accumulate values other than the value specified for impedanceAttribute. | RouteParameters | ||
An authorization string used to access a resource or service. | RouteParameters | ||
Use this property to specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. | RouteParameters | ||
The name of the class. | Accessor | ||
The language that will be used when generating travel directions. | RouteParameters | ||
Specify the units for displaying travel distance in the driving directions. | RouteParameters | ||
Define the content and verbosity of the driving directions. | RouteParameters | ||
Specify the name of the formatting style for the directions. | RouteParameters | ||
Set the time-based impedance attribute to display the duration of a maneuver, such as "Go northwest on Alvorado St. | RouteParameters | ||
Use this property to specify whether the operation should reorder stops to find the optimized route. | RouteParameters | ||
Use this property to specify the number of decimal places in the response geometries returned by solve operation. | RouteParameters | ||
Use this property to specify the number of decimal places in the response geometries returned by solve operation. | RouteParameters | ||
Use this property to specify the number of decimal places in the response geometries returned by a solve operation. | RouteParameters | ||
Specify whether invalid input locations should be ignored when finding the best solution. | RouteParameters | ||
Specifies the impedance. | RouteParameters | ||
Use this property to specify by how much you want to simplify the route geometry returned by the operation. | RouteParameters | ||
Use this property to specify the units for the value specified for the outputGeometryPrecision parameter. | RouteParameters | ||
Use this property to specify the type of route features that are output by the operation. | RouteParameters | ||
Use this property to specify the spatial reference of the geometries, such as line or point features, returned by a solve operation. | RouteParameters | ||
Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems. | RouteParameters | ||
Use this property to specify one or more points that will act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. | RouteParameters | ||
Use this property to specify polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons. | RouteParameters | ||
Use this property to specify one or more lines that prohibit travel anywhere the lines intersect the streets. | RouteParameters | ||
Use this property to indicate whether the operation should keep the first stop fixed when reordering the stops. | RouteParameters | ||
Use this property to indicate whether the operation should keep the last stop fixed when reordering the stops. | RouteParameters | ||
Use this property to specify if the Object IDs specified for input locations such as stops or barriers should be preserved when the input locations are returned as output. | RouteParameters | ||
Use this property to specify which restrictions should be honored by the operation. | RouteParameters | ||
Use this property to restrict or permit the route from making U-turns at junctions. | RouteParameters | ||
Specify whether point barriers will be returned by the routing operation. | RouteParameters | ||
Specify whether the operation should generate driving directions for each route. | RouteParameters | ||
Specify whether polygon barriers will be returned by the routing operation. | RouteParameters | ||
Specify whether polyline barriers will be returned by the routing operation. | RouteParameters | ||
Use this property to specify if the operation should return routes. | RouteParameters | ||
Use this property to specify whether stops will be returned by the routing operation. | RouteParameters | ||
Specify whether traversed edges will be returned by the operation. | RouteParameters | ||
Specify whether traversed junctions will be returned by the operation. | RouteParameters | ||
Specify whether traversed turns will be returned by the operation. | RouteParameters | ||
Include z values for the returned geometries if supported by the underlying network. | RouteParameters | ||
Indicates the time that travel should begin. | RouteParameters | ||
Specify the time zone or zones of the startTime property. | RouteParameters | ||
Specifies the locations the output route or routes will visit. | RouteParameters | ||
Specify whether the timeWindowStart and timeWindowEnd property values on stops are specified in UTC or geographically local time. | RouteParameters | ||
A travel mode represents a means of transportation, such as driving or walking. | RouteParameters | ||
Specify whether hierarchy should be used when finding the shortest paths. | RouteParameters | ||
Use this property to indicate whether the operation should consider time windows specified on the stops when finding the best route. | RouteParameters |
Property Details
-
Use this property to specify whether the operation should accumulate values other than the value specified for impedanceAttribute. For example, if your impedanceAttribute is set to
TravelTime
, the total travel time for the route will be calculated by the operation. However, if you also want to calculate the total distance of the route in miles, you can specifyMiles
as the value for the accumulateAttributes property.Possible Values:"kilometers" |"miles" |"minutes" |"travel-time" |"truck-minutes" |"truck-travel-time" |"walk-time" |"string"
-
apiKey
apiKey String
-
An authorization string used to access a resource or service. API keys are generated and managed in the portal. An API key is tied explicitly to an ArcGIS account; it is also used to monitor service usage. Setting a fine-grained API key on a specific class overrides the global API key.
Exampleconst stops = new FeatureSet({ features: [ new Graphic({ geometry: new Point({ x: -117.1949676, y: 34.0571844 }) }), new Graphic({ geometry: new Point({ x: -117.0619917, y: 34.0010284 }) }) ] }); const routeParameters = new RouteParameters({ apiKey: "YOUR_API_KEY", stops }); const routeURL = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"; const routeContainer = await route.solve(routeURL, routeParameters); const routeLayer = routeContainer.routeResults[0].route; const { attributes, geometry } = routeLayer; view.graphics.add(new Graphic({ attributes, geometry, symbol: { type: "simple-line", color: "green", width: "8px" } }));
-
attributeParameterValues
attributeParameterValues AttributeParameterValue[]
-
Use this property to specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. If the restriction is meant to avoid or prefer roads, you can further specify the degree to which they are avoided or preferred using this property. For example, you can choose to never use toll roads, avoid them as much as possible, or prefer them.
- See also
-
directionsLanguage
directionsLanguage String
-
The language that will be used when generating travel directions. This parameter applies only when the returnDirections parameter is set to
true
. The service supports generating directions in the following languages:ar
,bg
,bs
,ca
,cs
,da
,de
,el
,en
,es
,et
,fi
,fr
,he
,hr
,hu
,id
,it
,ja
,ko
,lt
,lv
,nb
,nl
,pl
,pt-BR
,pt-PT
,ro
,ru
,sk
,sl
,sr
,sv
,th
,tr
,uk
,vi
,zh-CN
,zh-HK
andzh-TW
.- See also
-
directionsLengthUnits
directionsLengthUnits String
-
Specify the units for displaying travel distance in the driving directions. This property applies only when the returnDirections property is set to
true
.Possible Values:"centimeters" |"decimal-degrees" |"decimeters" |"feet" |"inches" |"kilometers" |"meters" |"miles" |"millimeters" |"nautical-miles" |"points" |"yards"
- See also
-
directionsOutputType
directionsOutputType String
-
Define the content and verbosity of the driving directions. This property applies only when the returnDirections property is set to
true
.Possible Values:"complete" |"complete-no-events" |"featuresets" |"instructions-only" |"standard" |"summary-only"
- See also
-
directionsStyleName
directionsStyleName String
-
Specify the name of the formatting style for the directions. This property applies only when the returnDirections property is set to
true
.Possible Values:"desktop" |"navigation" |"campus"
- See also
-
directionsTimeAttribute
directionsTimeAttribute String
-
Set the time-based impedance attribute to display the duration of a maneuver, such as "Go northwest on Alvorado St. for 5 minutes." The units for all the time attributes is minutes.
Possible Values:"travel-time" |"truck-travel-time" |"walk-time" |"minutes" |"truck-time"
- See also
-
findBestSequence
findBestSequence Boolean
-
Use this property to specify whether the operation should reorder stops to find the optimized route. If the property value is
false
, the operation returns a route that visits stops in the order you define. If the parameter value istrue
, the operation finds the best order to visit the stops. The operation will account for a variety of variables so that the total travel distance or travel time for the route is minimized. You can elect to preserve the origin and the destination stops while allowing the operation to reorder intermediary stops by setting the preserveFirstStop and preserveLastStop properties.- See also
-
geometryPrecision
geometryPrecision Number
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, geometryPrecision added at 4.24. -
Use this property to specify the number of decimal places in the response geometries returned by solve operation. This applies to x- and y-values only (not m- or z-values).
- See also
-
geometryPrecisionM
geometryPrecisionM Number
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, geometryPrecisionM added at 4.24. -
Use this property to specify the number of decimal places in the response geometries returned by solve operation. This applies to m-value only (not x-,y- or z-values).
- See also
-
geometryPrecisionZ
geometryPrecisionZ Number
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, geometryPrecisionZ added at 4.24. -
Use this property to specify the number of decimal places in the response geometries returned by a solve operation. This applies to z-value only (not x-,y- or m-values).
- See also
-
ignoreInvalidLocations
ignoreInvalidLocations Boolean
-
Specify whether invalid input locations should be ignored when finding the best solution. An input point is deemed invalid by the operation if it is not within the maximum snap tolerance of any traversable street. When
true
invalid points are ignored. Whenfalse
any invalid point in your request will cause the operation to return a failure.- See also
-
impedanceAttribute
impedanceAttribute String
-
Specifies the impedance.
Impedance is a value that quantifies travel along the transportation network. Travel distance is an example of impedance; it quantifies the length of walkways and road segments. Similarly, drive time—the typical time it takes to drive a car along a road segment—is an example of impedance. This property will be ignored if travelMode is set.
Possible Values:"kilometers" |"miles" |"minutes" |"travel-time" |"truck-minutes" |"truck-travel-time" |"walk-time"
- See also
-
outputGeometryPrecision
outputGeometryPrecision Number
-
Use this property to specify by how much you want to simplify the route geometry returned by the operation. Simplification maintains critical points on a route, such as turns at intersections, to define the essential shape of the route and removes other points. The value of this property, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.
The units are specified with the outputGeometryPrecisionUnits parameter.
- See also
-
outputGeometryPrecisionUnits
outputGeometryPrecisionUnits String
-
Use this property to specify the units for the value specified for the outputGeometryPrecision parameter. The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.
Possible Values:"centimeters" |"decimal-degrees" |"decimeters" |"feet" |"inches" |"kilometers" |"meters" |"miles" |"millimeters" |"nautical-miles" |"points" |"yards"
- See also
-
outputLines
outputLines String
-
Use this property to specify the type of route features that are output by the operation. This parameter is applicable only if the returnRoutes parameter is set to
true
.Possible Value Description none Do not return any shapes for the routes. straight Return a straight line between the stops. true-shape Return the exact shape of the resulting route that is based on the underlying streets. true-shape-with-measure Return the exact shape of the resulting route that is based on the underlying streets and include route measurements that keep track of the cumulative travel time or travel distance along the route relative to the first stop. Possible Values:"none" |"straight" |"true-shape" |"true-shape-with-measure"
- Default Value:"true-shape"
- See also
-
outSpatialReference
outSpatialReference SpatialReference
-
Use this property to specify the spatial reference of the geometries, such as line or point features, returned by a solve operation.
- See also
-
pointBarriers
pointBarriers Collection<PointBarrier> |DataLayer |FeatureSet |NetworkFeatureSet |NetworkUrl
-
Use this property to specify one or more points that will act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. For example, a point barrier can be used to represent a fallen tree along a street or a time delay spent at a railroad crossing.
- See also
-
polygonBarriers
polygonBarriers Collection<PolygonBarrier> |DataLayer |FeatureSet |NetworkFeatureSet |NetworkUrl
-
Use this property to specify polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.
- See also
-
polylineBarriers
polylineBarriers Collection<PolylineBarrier> |DataLayer |FeatureSet |NetworkFeatureSet |NetworkUrl
-
Use this property to specify one or more lines that prohibit travel anywhere the lines intersect the streets. For example, a parade or protest that blocks traffic across several street segments can be modeled with a line barrier.
- See also
-
preserveFirstStop
preserveFirstStop Boolean
-
Use this property to indicate whether the operation should keep the first stop fixed when reordering the stops. This property is applicable only if the findBestSequence parameter value is
true
.- See also
-
preserveLastStop
preserveLastStop Boolean
-
Use this property to indicate whether the operation should keep the last stop fixed when reordering the stops. This property is applicable only if the findBestSequence parameter value is
true
.- See also
-
preserveObjectID
preserveObjectID Boolean
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, preserveObjectID added at 4.24. -
Use this property to specify if the Object IDs specified for input locations such as stops or barriers should be preserved when the input locations are returned as output.
- See also
-
Use this property to specify which restrictions should be honored by the operation. A restriction represents a driving preference or requirement. This value is ignored if travelMode is specified.
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"
- See also
-
restrictUTurns
restrictUTurns String
-
Use this property to restrict or permit the route from making U-turns at junctions. This value is ignored if travelMode is specified.
Possible Values:"allow-backtrack" |"at-dead-ends-only" |"no-backtrack" |"at-dead-ends-and-intersections"
- See also
-
returnBarriers
returnBarriers Boolean
-
Specify whether point barriers will be returned by the routing operation.
- Default Value:false
- See also
-
returnDirections
returnDirections Boolean
-
Specify whether the operation should generate driving directions for each route. If
true
directions are configured based on the values for the directionsLanguage, directionsOutputType, directionsStyleName, and directionsLengthUnits properties.- Default Value:false
- See also
-
returnPolygonBarriers
returnPolygonBarriers Boolean
-
Specify whether polygon barriers will be returned by the routing operation.
- Default Value:false
- See also
-
returnPolylineBarriers
returnPolylineBarriers Boolean
-
Specify whether polyline barriers will be returned by the routing operation.
- Default Value:false
- See also
-
returnRoutes
returnRoutes Boolean
-
Use this property to specify if the operation should return routes. If
true
, the shape of the routes depends on the value for the outputLines property.- Default Value:true
- See also
-
returnTraversedEdges
returnTraversedEdges Boolean
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, returnTraversedEdges added at 4.24. -
Specify whether traversed edges will be returned by the operation.
- See also
-
returnTraversedJunctions
returnTraversedJunctions Boolean
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, returnTraversedJunctions added at 4.24. -
Specify whether traversed junctions will be returned by the operation.
- See also
-
returnTraversedTurns
returnTraversedTurns Boolean
Since: ArcGIS Maps SDK for JavaScript 4.24RouteParameters since 4.20, returnTraversedTurns added at 4.24. -
Specify whether traversed turns will be returned by the operation.
- See also
-
Indicates the time that travel should begin. Please note that the "now" keyword is only supported on servers with a version of 10.8.1 or greater. If a start time is not provided, the route is based on historically average traffic conditions, average speeds, and posted speed limits.
When a startTime of "now" is used the startTimeIsUTC property is ignored.
For RouteParameters the startTime is always "now".
- Default Value:null
- See also
-
stops
stops Collection<Stop> |DataLayer |FeatureSet |NetworkFeatureSet |NetworkUrl
-
Specifies the locations the output route or routes will visit.
- See also
Examples// Define stops using a FeatureSet. const routeParameters = new RouteParameters({ stops: new FeatureSet({ features: [ new Graphic({ attributes: { Name: "Redlands" }, geometry: new Point({ x: -117.1825, y: 34.054722 }) }), new Graphic({ attributes: { Name: "Palm Springs" }, geometry: new Point({ x: -116.545278, y: 33.830278 }) }) ] }) });
// Define stops using a collection of Stops. const routeParameters = new RouteParameters({ stops: new Collection([ new Stop({ name: "Redlands", geometry: { x: -117.1825, y: 34.054722 }}), new Stop({ name: "Palm Springs", geometry: { x: -116.545278, y: 33.830278 }}) ]) });
-
travelMode
travelMode TravelMode
-
A travel mode represents a means of transportation, such as driving or walking. Travel modes define the physical characteristics of a vehicle or pedestrian.
Use networkService.fetchServiceDescription to obtain a list of predefined travel modes and the default travel mode that is used if one is not specified in a routing reqest.
Example// Display the fastest walking time route between two existing graphics. const apiKey = "<your-api-key>"; const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"; // Obtain the routing service's description. The description contains all preset travel modes. const serviceDescription = await networkService.fetchServiceDescription(url, apiKey); // Find the named travel mode called "Walking Time". const { supportedTravelModes } = serviceDescription; const travelMode = supportedTravelModes.find((mode) => mode.name === "Walking Time"); // Construct the route parameter object. const routeParameters = new RouteParameters({ apiKey, stops: new FeatureSet({ features: view.graphics.toArray() }), returnDirections: true, travelMode }); // Solve the route and add the path representing the fastest walk path to the map. const routeContainer = await route.solve(url, routeParameters); for (const routeResult of routeContainer.routeResults) { const { routeLayer } = routeResult; routeLayer.symbol = { type: "simple-line", color: [5, 150, 255], width: 3 }; view.graphics.add(routeLayer); }
-
useHierarchy
useHierarchy Boolean
-
Specify whether hierarchy should be used when finding the shortest paths. This value is ignored if a travelMode is specified.
- See also
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. | RouteParameters | |
* | Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. | RouteParameters | |
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. | RouteParameters |
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.
Type Definitions
-
An object describing the parameter values for the attributeParameterValues property of RouteParameters.