DirectionsFeature

AMD: require(["esri/rest/support/DirectionsFeature"], (DirectionsFeature) => { /* code goes here */ });
ESM: import DirectionsFeature from "@arcgis/core/rest/support/DirectionsFeature.js";
Class: esri/rest/support/DirectionsFeature
Inheritance: DirectionsFeatureGraphic
Since: ArcGIS Maps SDK 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 = SpatialReference.WebMercator;

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

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

DirectionsFeature

An array of Direction Events.

DirectionsFeature

The geometry of the Directions Feature.

DirectionsFeature

An array of direction strings.

DirectionsFeature

Property Details

attributes

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

events

Property
events DirectionsEvent[]

An array of Direction Events.

geometry

Property
geometry Polyline

The geometry of the Directions Feature.

strings

Property
strings DirectionsString[]

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.