Skip to content
import { execute, getDepots, getOrders, getRoutes, getCost } from "@arcgis/core/rest/lastMileDelivery.js";
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.

See also

Type definitions

Cost

Type definition

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

numberOfObjects

Property
Type
number

The number of billable objects.

credits

Property
Type
number

The number of credits consumed.

GetResultOptions

Type definition
Supertypes
Partial<Pick<GPOptions, "outSpatialReference" | "processExtent" | "returnM" | "returnZ">>

Functions

execute

Function

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

Signature
execute (url: string, parameters: LastMileDeliveryParameters, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<JobInfo>
Parameters
ParameterTypeDescriptionRequired
url

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

parameters

Parameters needed to configure the last mile delivery solver.

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
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),
]);

getDepots

Function

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

See also
Signature
getDepots (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<FeatureSet>

When resolved, returns an instance of FeatureSet.

getOrders

Function

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.

See also
Signature
getOrders (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<FeatureSet>

When resolved, returns an instance of FeatureSet.

getRoutes

Function

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

See also
Signature
getRoutes (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<FeatureSet>

When resolved, returns an instance of FeatureSet.

getCost

Function

Returns the credits used by the analysis.

See also
Signature
getCost (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<Cost>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<Cost>

When resolved, returns an instance of Cost.

getDirectionPoints

Function

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.

See also
Signature
getDirectionPoints (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<FeatureSet>

When resolved, returns an instance of FeatureSet.

getDepotVisits

Function

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

See also
Signature
getDepotVisits (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<FeatureSet>

When resolved, returns an instance of FeatureSet.

getDirectionLines

Function

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

See also
Signature
getDirectionLines (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
ParameterTypeDescriptionRequired
jobInfo

the JobInfo result from execute

options

Processing options.

requestOptions

Additional options to be used for the data request.

Returns
Promise<FeatureSet>

When resolved, returns an instance of FeatureSet.