L.esri.GP.Task

Extends L.esri.Task

An abstraction to simplify making calls to ArcGIS Online and ArcGIS Server Geoprocessing services. You can find more information and the source code for this plugin here.

Constructor

This object is typically instantiated by calling L.esri.GP.Service.createTask()

Events

By default, the plugin assumes services are synchronous and that 'execute' is the appropriate path.

If you are working with an asynchronous service or one with a custom operation name and don't indicate corresponding information in the constructor, you'll have to leave the plugin enough time to make a roundtrip to the server to inquire before calling run().

The GP.task 'initialized' event is intended to help with this timing.

Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
var myService = L.esri.GP.service({
    url: 'https://elevation.arcgis.com/arcgis/rest/services/Tools/ElevationSync/GPServer/Profile'
});
var myTask = myService.createTask();

    myTask.on('initialized', function () {
    myTask.setParam('inputFeature', polyline.toGeoJSON());
    myTask.run(function (error, geojson, response) {
    ...
    });
});

Methods

MethodReturnsDescription
setParam(<String>inputParamName, <String||Boolean||Geometry>value)thisSets an input parameter named by the service itself. L.LatLng, L.Marker, L.LatLngBounds , and L.GeoJSON (both Features and Geometries) will be converted to GeoServices JSON to be passed in the request automatically.
run(<Function>callback)thisCalls the corresponding Geoprocessing service, passing the previously supplied input parameters. For synchronous services, **all** result parameters are parsed and returned.
setOutputParam(<String>outputParamName)this(Optional) Only applicable for asynchronous services. Notifies the plugin of the parameter name to retrieve output for.
gpAsyncResultParam(<String>resultParamName, <Object>value)this(Optional) Sets a result parameter for Asynchronous geoprocessing services that require it.

Results

The response from synchronous services will be a JSON object composed of name value pairs of output parameter names and their associated values. GPFeatureRecordSet layer output will converted to GeoJSON.

A single result from the geoprocessing service. Do not rely on all these properties being present in every result object.

PropertyTypeDescription
jobId<String>ID of processed job (only applicable for asynchronous services).
outputMapService<String>Url of temporary map service created by geoprocessing service, if its been designed to create one.

GP results conform to the following format

Use dark colors for code blocksCopy
             
1
2
3
4
5
6
7
8
9
10
11
12
13
[
    {
    // actual parameter name and data type are dependent on the service itself
        outputParamName: <L.GeoJSON> || <string> || <boolean>,
        outputGPFileParamName: {
        url: 'https://server/arcgis/rest/directories/arcgisoutput/./_ags_856aed6eb_.png'
        }
    },
    {
    jobId: 'j7123be34ccfe45b4b47a51e867e0084b',
    mapService: 'https://server/arcgis/rest/services/GPServiceName/MapServer/jobs/j7123be34ccfe45b4b47a51e867e0084b/'
    }
]

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