import { execute, getDepots, getOrders, getRoutes, getCost } from "@arcgis/core/rest/lastMileDelivery.js";const { execute, getDepots, getOrders, getRoutes, getCost } = await $arcgis.import("@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.
Type definitions
Cost
The cost of the analysis, including the number of billable objects and the number of credits consumed.
Functions
execute
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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. | |
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
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
Returns the credits used by the analysis.
- See also
- Signature
-
getCost (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<Cost>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| jobInfo | the JobInfo result from execute | | |
| options | Processing options. | | |
| requestOptions | Additional options to be used for the data request. | |
getDirectionPoints
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.
- Signature
-
getDirectionPoints (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
The output route lines calculated in the analysis sliced to represent each route segment between direction points events or maneuver locations.
- Signature
-
getDirectionLines (jobInfo: JobInfo, options?: GetResultOptions, requestOptions?: RequestOptions): Promise<FeatureSet>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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.