closestFacility

AMD: require(["esri/rest/closestFacility"], (closestFacility) => { /* code goes here */ });
ESM: import * as closestFacility from "@arcgis/core/rest/closestFacility.js";
Object: esri/rest/closestFacility
Since: ArcGIS Maps SDK for JavaScript 4.19

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 must be defined using ClosestFacilityParameters and input to the solve() method.

Method Overview

Name Return Type Summary Object

Solves the closest facility.

closestFacility

Method Details

solve

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

Solves the closest facility.

Parameters
url String

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

Defines the parameters of the closest facility analysis.

requestOptions Object
optional

Additional options to be used for the data request.

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

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