import RouteInfo from "@arcgis/core/rest/support/RouteInfo.js";const RouteInfo = await $arcgis.import("@arcgis/core/rest/support/RouteInfo.js");- Inheritance:
- RouteInfo→
Accessor
- 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 metersConstructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
type readonly | "route-info" | |
popupTemplate
- 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.
Methods
| Method | Signature | Class |
|---|---|---|
fromGraphic static | fromGraphic(graphic: Graphic): RouteInfo | |
fromJSON inherited static | fromJSON(json: any): any | |
clone inherited | clone(): this | |
toGraphic(): Graphic | | |
toJSON inherited | toJSON(): any |
fromJSON
- Signature
-
fromJSON (json: any): any
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | 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
- Signature
-
clone (): this
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.
toJSON
- Signature
-
toJSON (): any
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.