ClosestFacilityTask

require(["esri/tasks/ClosestFacilityTask"], function(ClosestFacilityTask) { /* code goes here */ });
Class: esri/tasks/ClosestFacilityTask
Inheritance: ClosestFacilityTask Task Accessor
Since: ArcGIS API for JavaScript 4.0

Helps you find closest facilities around any location (incident) on a network.

When finding closest facilities, you can specify various parameters including how many to facilities to find and whether the direction of travel is toward or away from them. Once you've found the closest facilities, you can display the best route to or from them, return the travel cost for each route, and display directions to each facility using the ClosestFacilitySolveResult.

You can also specify a cutoff cost beyond which ArcGIS Network Analyst should not search for a facility. For instance, you can set up a closest facility problem to search for hospitals within a 15-minute drive time of the site of an accident. Any hospitals that take longer than 15 minutes to reach will not be included in the results.

Parameters for this tasks must be defined using ClosestFacilityParameters and input to the solve() method.

ClosestFacilityTask and other closest facility related classes require a "closest facility" layer. A closest facility layer is a layer of type esriNAServerClosestFacilityLayer.

See also:

Constructors

new ClosestFacilityTask(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The name of the class.

more details
more detailsAccessor
Object

The options to be used for data requests.

more details
more detailsTask
String

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

more details
more detailsClosestFacilityTask

Property Details

declaredClassStringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

requestOptionsObject inherited

The options to be used for data requests. These options can also be controlled through the requestOptions method parameter.

URL to the ArcGIS Server REST resource that represents a network analysis service. Use the Service Directory to obtain the URL.

Method Overview

NameReturn TypeSummaryClass
Promise<ClosestFacilitySolveResult>

Solves the closest facility.

more details
more detailsClosestFacilityTask

Method Details

solve(params, requestOptions){Promise<ClosestFacilitySolveResult>}

Solves the closest facility.

Parameters:

Defines the parameters of the closest facility analysis.

requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
TypeDescription
Promise<ClosestFacilitySolveResult>When resolved, returns an instance of ClosestFacilitySolveResult
Example:
closestFacilityTask.solve(params).then(function(solveResult){
  // Do something with the solveResults here
});

API Reference search results

NameTypeModule
Loading...