import * as lastMileDelivery from "@arcgis/core/rest/lastMileDelivery.js";
const lastMileDelivery = await $arcgis.import("@arcgis/core/rest/lastMileDelivery.js");
@arcgis/core/rest/lastMileDelivery
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
Methodexecute(url, parameters, options, requestOptions){Promise<JobInfo>} -
Determines the optimized routes for a fleet of vehicles that need to make deliveries.
Parametersurl StringURL to the ArcGIS Server REST resource that represents a network analysis service.
parameters LastMileDeliveryParametersParameters needed to configure the last mile delivery solver.
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when
routeShapeisshape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsExampleconst 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
MethodgetCost(jobInfo, options, requestOptions){Promise<Cost>} -
Returns the credits used by the analysis.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
Returns- See also
-
getDepotVisits
MethodgetDepotVisits(jobInfo, options, requestOptions){Promise<FeatureSet>} -
Provides information regarding why a route visited a depot and what happened there.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsType Description Promise<FeatureSet> When resolved, returns an instance of FeatureSet. - See also
-
getDepots
MethodgetDepots(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.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsType Description Promise<FeatureSet> When resolved, returns an instance of FeatureSet. - See also
-
getDirectionLines
MethodgetDirectionLines(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.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsType Description Promise<FeatureSet> When resolved, returns an instance of FeatureSet. - See also
-
getDirectionPoints
MethodgetDirectionPoints(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.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsType Description Promise<FeatureSet> When resolved, returns an instance of FeatureSet. - See also
-
getOrders
MethodgetOrders(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.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsType Description Promise<FeatureSet> When resolved, returns an instance of FeatureSet. - See also
-
getRoutes
MethodgetRoutes(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.
ParametersjobInfo JobInfothe JobInfo result from execute
options ObjectoptionalProcessing options.
SpecificationoutSpatialReference SpatialReference|null|undefinedoptionalOutput spatial refeference.
optional Limits processing to features within this extent.
returnM BooleanoptionalReturns geometry with measures when routeShape is
shape-with-measures.returnZ BooleanoptionalReturns geometry with heights (z) if and when the source network dataset contains height information.
requestOptions RequestOptionsoptionalAdditional options to be used for the data request.
ReturnsType Description Promise<FeatureSet> When resolved, returns an instance of FeatureSet. - See also