Skip to content
ESM: import * as lastMileDelivery from "@arcgis/core/rest/lastMileDelivery.js";
CDN: const lastMileDelivery = await $arcgis.import("@arcgis/core/rest/lastMileDelivery.js");
Object: @arcgis/core/rest/lastMileDelivery
Since: ArcGIS Maps SDK for JavaScript 4.34

Last Mile Delivery is a type of Vehicle Routing Problem operation that can find the most optimized routes for a fleet of vehicles that need to make deliveries. It is specifically tailored to the unique challenges of final deliveries, focusing on efficiency in dense urban environments. It produces geographically clustered routes so drivers can easily visit each location, which minimizes the operating cost for the fleet of vehicles.

Method Overview

Name Return Type Summary Object
Promise<JobInfo>

Determines the optimized routes for a fleet of vehicles that need to make deliveries.

lastMileDelivery
Promise<Cost>

Returns the credits used by the analysis.

lastMileDelivery
Promise<FeatureSet>

Provides information regarding why a route visited a depot and what happened there.

lastMileDelivery
Promise<FeatureSet>

Contains all the fields from the input depots parameter, as well as the following fields that are either generated or altered by the service.

lastMileDelivery
Promise<FeatureSet>

The output route lines calculated in the analysis sliced to represent each route segment between direction points events or maneuver locations.

lastMileDelivery
Promise<FeatureSet>

Specifies the output turn-by-turn directions for the routes calculated in the analysis, represented as point locations along the routes where specific direction events or maneuvers occur.

lastMileDelivery
Promise<FeatureSet>

Contains all the attributes from input orders parameter, this includes the attributes defined on the service, and also attributes that are pass-through (you can pass additional attributes on input orders and those attributes will be carried over to the output).

lastMileDelivery
Promise<FeatureSet>

Contains all the fields from the input routes parameter, as well as the following fields that are either generated or altered by the service.

lastMileDelivery

Method Details

execute

Method
execute(url, parameters, options, requestOptions){Promise<JobInfo>}

Determines the optimized routes for a fleet of vehicles that need to make deliveries.

Parameters
url String

URL to the ArcGIS Server REST resource that represents a network analysis service.

Parameters needed to configure the last mile delivery solver.

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<JobInfo> When resolved, returns an instance of JobInfo.
Example
const apiKey = "YOUR_API_KEY";
const url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveLastMileDelivery";
const parameters = new LastMileDeliveryParameters({
  apiKey,
  depots: new FeatureSet({ features: {  <An array of graphics>  } }),
  orders: new FeatureSet({ features: {  <An array of graphics>  } }),
  routes: new FeatureSet({ features: {  <An array of graphics>  } }),
  earliestRouteStartDate: "2024-02-02",
  maxRouteTotalTime: 480,
)};

// Returns job-id when async job is complete.
const jobInfo = await lastMileDelivery.exectute(url, parameters);

const requestOptions = { query: { token: parameters.apiKey } };
const [depots, orders, routes, cost] = await Promise.all([
  getDepots(jobInfo, null, requestOptions),
  getOrders(jobInfo, null, requestOptions),
  getRoutes(jobInfo, null, requestOptions),
  getCost(jobInfo, null, requestOptions),
]);

getCost

Method
getCost(jobInfo, options, requestOptions){Promise<Cost>}

Returns the credits used by the analysis.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<Cost> When resolved, returns an instance of Cost.

getDepotVisits

Method
getDepotVisits(jobInfo, options, requestOptions){Promise<FeatureSet>}

Provides information regarding why a route visited a depot and what happened there.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<FeatureSet> When resolved, returns an instance of FeatureSet.

getDepots

Method
getDepots(jobInfo, options, requestOptions){Promise<FeatureSet>}

Contains all the fields from the input depots parameter, as well as the following fields that are either generated or altered by the service.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<FeatureSet> When resolved, returns an instance of FeatureSet.

getDirectionLines

Method
getDirectionLines(jobInfo, options, requestOptions){Promise<FeatureSet>}

The output route lines calculated in the analysis sliced to represent each route segment between direction points events or maneuver locations.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<FeatureSet> When resolved, returns an instance of FeatureSet.

getDirectionPoints

Method
getDirectionPoints(jobInfo, options, requestOptions){Promise<FeatureSet>}

Specifies the output turn-by-turn directions for the routes calculated in the analysis, represented as point locations along the routes where specific direction events or maneuvers occur.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<FeatureSet> When resolved, returns an instance of FeatureSet.

getOrders

Method
getOrders(jobInfo, options, requestOptions){Promise<FeatureSet>}

Contains all the attributes from input orders parameter, this includes the attributes defined on the service, and also attributes that are pass-through (you can pass additional attributes on input orders and those attributes will be carried over to the output). The output also contains following attributes that are either generated or altered by the service.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<FeatureSet> When resolved, returns an instance of FeatureSet.

getRoutes

Method
getRoutes(jobInfo, options, requestOptions){Promise<FeatureSet>}

Contains all the fields from the input routes parameter, as well as the following fields that are either generated or altered by the service.

Parameters
jobInfo JobInfo

the JobInfo result from execute

options Object
optional

Processing options.

Specification
outSpatialReference SpatialReference|null|undefined
optional

Output spatial refeference.

processExtent Extent|null|undefined
optional

Limits processing to features within this extent.

returnM Boolean
optional

Returns geometry with measures when routeShape is shape-with-measures.

returnZ Boolean
optional

Returns geometry with heights (z) if and when the source network dataset contains height information.

requestOptions RequestOptions
optional

Additional options to be used for the data request.

Returns
Type Description
Promise<FeatureSet> When resolved, returns an instance of FeatureSet.

Type Definitions

Cost

Type Definition
Cost Object

The cost of the analysis, including the number of billable objects and the number of credits consumed.

Properties
numberOfObjects Number

The number of billable objects.

credits Number

The number of credits consumed.

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