dojo.require("esri.tasks.closestfacility");
Description
(Added at v2.0)
Helps you find closest facilities around any location (incident) on a network.
When finding closest facilities, you can specify how many 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.
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.
Note: ClosestFacilityTask, and other closest facility related classes, requires ArcGIS Server 10.0 or above and a "closest facility" layer. A closest facility layer is a layer of type esriNAServerClosestFacilityLayer.
See also
Samples
Search for
samples that use this class.
Constructors
Methods
Events
[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
Constructor Details
Creates a new ClosestFacilityTask object.
Parameters:
<String > url |
Required |
URL to the ArcGIS Server REST resource that represents a network analysis service. Use the Service Directory to obtain the URL. |
Sample:
var closestFacilityTask = new esri.tasks.ClosestFacilityTask("http://174.129.22.43/ArcGIS/rest/services/Network/USA/NAServer/Closest Facility");
Method Details
Returns an object describing a Closest Facility service endpoint (URL of the endpoint is specified in the constructor). The description contains information about the default solver settings, underlying network dataset, available cost and restriction attributes, supported travel modes, etc. If the targeted Network Analyst Server is federated with a Portal or ArcGIS Online, the returned
supportedTravelModes
array will include user-specific travel modes. If the Network Analyst Server works in a standalone configuration, the
supportedTravelModes
will come from the original Closest Facility service description.
A few properties returned in this object include: attributeParameterValues
, impedance
, restrictUTurns
, restrictions
, supportedTravelModes
, travelDirection
, and useHierarchy
.
(Added at v3.14)
Solve the closest facility.
Parameters:
<ClosestFacilityParameters > params |
Required |
The ClosestFacilityParameters object. |
<Function > callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onSolveComplete event. |
<Function > errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. |
Sample:
closestFacilityTask.solve(params,function(solveResult){
//do something with the solve results here
});
Event Details
[ On Style Events | Connect Style Event ]
Fires when ClosestFacilityTask has completed. Should be used in favor of onSolveComplete. (Added at v3.5)
Fired when the ClosestFacilityTask solve is complete.