Skip to content
import RouteInfo from "@arcgis/core/rest/support/RouteInfo.js";
Inheritance:
RouteInfoAccessor
Since
ArcGIS Maps SDK for JavaScript 4.23

A RouteInfo contains information about a solved route including the routes geometry and overall distance and time.

See also
Example
// Display the route name and overall distance and duration.
const routeLayer = new RouteLayer({
portalItem: {
id: "69569b47b1e445b8a42ec12feab41ce9"
}
});
await routeLayer.load();
const locale = "en-US";
const formatMinutes = new Intl.NumberFormat(locale, {
minimumFractionDigits: 1,
maximumFractionDigits: 1
});
const formatDistance = new Intl.NumberFormat(locale, {
minimumFractionDigits: 0,
maximumFractionDigits: 0
});
const formatDate = new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZone: "America/Los_Angeles"
});
const { name, startTime, endTime, totalDistance, totalDuration } = routeLayer.routeInfo;
console.log(`Route name: ${name}`);
console.log(`Start Time: ${formatDate.format(startTime)}`);
console.log(`End Time: ${formatDate.format(endTime)}`);
console.log(`Travel Time: ${formatMinutes.format(totalDuration)} minutes`);
console.log(`Travel Distance: ${formatDistance.format(totalDistance)} meters`);
// Route name: Kenoak Pl, Pomona, California, 91768 — 16561 Valley Blvd, Fontana, California, 92335
// Start Time: 12/7/2020, 3:58:50 PM
// End Time: 12/7/2020, 6:12:20 PM
// Travel Time: 133.5 minutes
// Travel Distance: 173,148 meters

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

endTime

autocast Property
Type
Date | null | undefined

The end time of the route.

endTimeOffset

Property
Type
number | null | undefined

The local time offset (in minutes) for the end time.

geometry

autocast Property
Type
Polyline | null | undefined

Polyline representing the route's geometry.

name

Property
Type
string | null | undefined

User specified route name.

popupTemplate

autocast Property
Type
PopupTemplate | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.30

The template for displaying content in a Popup when the graphic is selected.

startTime

autocast Property
Type
Date | null | undefined

The start time of the route.

startTimeOffset

Property
Type
number | null | undefined

The local time offset (in minutes) for the start time.

totalDistance

Property
Type
number | null | undefined

Total distance traveled in meters.

totalDuration

Property
Type
number | null | undefined

Total time in minutes.

type

readonly Property
Type
"route-info"

Methods

MethodSignatureClass
fromGraphic
static
fromGraphic(graphic: Graphic): RouteInfo
fromJSON
inherited static
fromJSON(json: any): any
clone
inherited
clone(): this
toGraphic(): Graphic
toJSON
inherited
toJSON(): any

fromGraphic

static Method
Signature
fromGraphic (graphic: Graphic): RouteInfo
Since
ArcGIS Maps SDK for JavaScript 4.24

Creates a RouteInfo from the parsed Graphic. The method assumes that the graphic's attributes conform to the route layer item schema.

Parameters
ParameterTypeDescriptionRequired
graphic

A Graphic instance.

Returns
RouteInfo

A RouteInfo instance.

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

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.

Parameters
ParameterTypeDescriptionRequired
json
any

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
any

Returns a new instance of this class.

clone

inherited Method
Signature
clone (): this
Inherited from: ClonableMixin

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.

Returns
this

A deep clone of the class instance that invoked this method.

toGraphic

Method
Signature
toGraphic (): Graphic
Since
ArcGIS Maps SDK for JavaScript 4.24

Creates a Graphic from the RouteInfo instance. The resulting graphic will have attributes that conform to the route layer item schema.

Returns
Graphic

A Graphic instance.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

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

Returns
any

The ArcGIS portal JSON representation of an instance of this class.