DirectionsFeature

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

DirectionsFeature is subclass of Graphic that contains routing specific attributes. This is accessible from the DirectionsFeatureSet.features property.

A DirectionsFeatureSet is only returned when a route is solved with an output type of "complete", "complete-no-events", "instructions-only", "standard", or "summary-only".

See also
Example
// If I leave Esri now, what time will I arrive at the Redlands Bowl?
const apiKey = "<ENTER YOUR API KEY HERE>";
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";

const spatialReference = new SpatialReference({ wkid: 102100 });

const stops = new Collection([
  new Stop({
    name: "Esri",
    geometry: new Point({ x: -13046165, y: 4036335, spatialReference })
  }),
  new Stop({
    name: "Redland Bowl",
    geometry: new Point({ x: -13045111, y: 4036114, spatialReference })
  })
]);

const routeParameters = new RouteParameters({
  apiKey,
  stops,
  startTime: new Date(),
  outSpatialReference: spatialReference,
  returnDirections: true,
  directionsOutputType: "standard" // default value
});

const { routeResults } = await route.solve(url, routeParameters);
const { directions } = routeResults[0];
const directionFeatures = directions.features;

const lastDirectionFeature = directionFeatures[directionFeatures.length - 1];
const arriveTimeEpoch = lastDirectionFeature.attributes["arriveTimeUTC"];
const arriveTimeDate = new Date(arriveTimeEpoch);

console.log(`I will arrive at: ${arriveTimeDate.toLocaleTimeString()}`);

Property Overview

Name Type Summary Class
Object

Name-value pairs of fields and field values associated with the Directions Feature.

more details
DirectionsFeature
DirectionsEvent[]

An array of Direction Events.

more details
DirectionsFeature
Polyline

The geometry of the Directions Feature.

more details
DirectionsFeature
DirectionsString[]

An array of direction strings.

more details
DirectionsFeature

Property Details

attributes Object

Name-value pairs of fields and field values associated with the Directions Feature. Fields include the following:

Field name Type Description
ETA Number The estimated arrival time in UTC in the local time zone.
arriveTimeUTC Number The estimated arrival time in UTC.
length Number The length of the route segment.
maneuverType String The maneuver type.
text String The driving direction text.
time Number The time spent travelling along the route segment.

An array of Direction Events.

geometry Polyline

The geometry of the Directions Feature.

An array of direction strings.

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