Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: ServiceAreaTask

require(["esri/tasks/ServiceAreaTask"], function(ServiceAreaTask) { /* code goes here */ });

Description

(Added at v2.0)
Helps you find service areas around any location on a network. A network service area is a region that encompasses all accessible streets that is, streets that are within a specified impedance. For instance, the 5-minute service area for a point includes all the streets that can be reached within five minutes from that point.

Note: ServiceAreaTask, and other service area related classes, requires ArcGIS Server 10.0 or above and a service area layer. A service area layer is a layer of type esriNAServerServiceAreaLayer.

See also
Service area analysis ArcGIS Desktop help topic.

Samples

Search for samples that use this class.

Constructors

NameSummary
new ServiceAreaTask(url)Creates a new ServiceAreaTask object.

Methods

NameReturn typeSummary
getServiceDescription()ObjectReturns an object describing a Service Area service endpoint (URL of the endpoint is specified in the constructor).
solve(params, callback?, errback?)DeferredSolve the service area.

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.

Events

NameEvent ObjectSummary
solve-complete
{
  result: <ServiceAreaSolveResult>
}
Fires when ServiceAreaTask has completed.
Constructor Details

new ServiceAreaTask(url)

Creates a new ServiceAreaTask 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:
require([
  "esri/tasks/ServiceAreaTask", ... 
], function(ServiceAreaTask, ... ) {
   var serviceAreaTask = new ServiceAreaTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ServiceArea");
  ...
});
Method Details

getServiceDescription()

Returns an object describing a Service Area 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)
Return type: Object

solve(params, callback?, errback?)

Solve the service area.
Return type: Deferred
Parameters:
<ServiceAreaParameters> params Required The ServiceAreaParameters 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:
serviceAreaTask.solve(params,function(serviceAreaSolveResult){
  var result = serviceAreaSolveResult;
  //do something with the results here
});
Event Details
[ On Style Events | Connect Style Event ]

solve-complete

Fires when ServiceAreaTask has completed. Should be used in favor of onSolveComplete. (Added at v3.5)
Event Object Properties:
<ServiceAreaSolveResult> result The results from the ServiceAreaTask solve operation.