ESM: import JobInfo from "@arcgis/core/rest/support/JobInfo.js";
CDN: const JobInfo = await $arcgis.import("@arcgis/core/rest/support/JobInfo.js");
Class: @arcgis/core/rest/support/JobInfo
Since: ArcGIS Maps SDK for JavaScript 4.20
Property Overview Any properties can be set, retrieved or listened to. See the Watch for changes topic.Show inherited properties Hide inherited properties
Property DetailsInherited
Property declaredClass Stringreadonly
The name of the class. The declared class name is formatted as esri.folder.className
.
The unique job ID assigned by geoprocessing server.
jobStatus String
The job status.
Possible Values:"job-cancelled" |"job-cancelling" |"job-deleted" |"job-deleting" |"job-timed-out" |"job-executing" |"job-failed" |"job-new" |"job-submitted" |"job-succeeded" |"job-waiting"
An array of messages that include a type and description.
Since: ArcGIS Maps SDK for JavaScript 4.26 JobInfo since 4.20, progress added at 4.26.
Displays the progress of the geoprocessing job. This value is only present when jobStatus is job-executing
and is only updated every five seconds.
Example
// Submit an asynchronous geoprocessing job
const jobInfo = await submitJob(url, params);
// Define a callback that will be called periodically. The function will print the
// geoprocessor's progress and percentage complete (if a step progressor).
const statusCallback = ({ jobStatus, progress }) => {
if (jobStatus !== "job-executing") { return; }
const { message, percent } = progress;
const status = `Message: ${message}
Progress: ${percent ?? "not specified"}`
console.log(`Status: ${status}`);
};
// Wait for the geoprocessing job to complete and print job progress
// to the console every five seconds
await jobInfo.waitForJobCompletion({ interval: 5000, statusCallback });
The options to be used for data requests. These options can also be controlled through the requestOptions
method parameter.
sourceUrl String
ArcGIS Server Rest API endpoint to the resource that receives the geoprocessing request.
Show inherited methods Hide inherited methods
Method DetailsInherited
Method addHandles(handleOrHandles, groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles
const handle = reactiveUtils.when(
() => !view.updating,
() => {
wkidSelect.disabled = false;
},
{ once: true }
);
this.addHandles(handle);
// Destroy the object
this.destroy();
Parameters
Handles marked for removal once the object is destroyed.
groupKey *
optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
cancelJob(requestOptions){Promise<JobInfo>}
Cancels an asynchronous geoprocessing job. The returned promise will only resolve when the geoprocessing job has canceled on the server.
Parameter
optionalAdditional options to be used for the data request (will override requestOptions defined during construction).
Returns
Example
// Cancel an ongoing geoprocessing job when the user clicks a "cancel" button.
document.getElementById("cancelButton").addEventListener("click", () => {
jobInfo.cancelJob().then(() => {
console.log("Job cancelled successfully.");
}).catch(() => {
console.log("Problem occurred which cancelling the geoproccessing job");
});
});
checkJobStatus(requestOptions){Promise<JobInfo>}
Sends a request for the current state of this job.
Parameter
optionalAdditional options to be used for the data request (will override requestOptions defined during construction).
Returns
Stop monitoring this job for status updates.
// Stop monitoring this job for status updates.
jobInfo.destroy();
fetchResultData(resultName, gpOptions, requestOptions){Promise<ParameterValue>}
Sends a request to the GP Task to get the task result identified by resultName
.
Parameters
The name of the result parameter as defined in Services Directory.
optionalInput options for the geoprocessing service return values.
optionalAdditional options to be used for the data request (will override requestOptions defined during construction).
Returns
Type Description Promise<ParameterValue> When resolved, returns an object with a property namedresult
of type ParameterValue, which contains the result parameters and the task execution messages.
fetchResultImage(resultName, imageParams, requestOptions){Promise<ParameterValue>}
Sends a request to the GP Task to get the task result identified by jobId
and resultName
as an image.
Parameters
The name of the result parameter as defined in the Services Directory.
Specifies the properties of the result image.
optionalAdditional options to be used for the data request (will override requestOptions defined during construction).
Returns
Type Description Promise<ParameterValue> When resolved, returns an Object with amapImage
property of type MapImage
fetchResultMapImageLayer(){Promise<MapImageLayer>}
Get the task result identified by jobId
as an MapImageLayer.
Returns
Type Description Promise<MapImageLayer> A promise resolving to an instance of MapImageLayer.Example
// Get the resulting map image layer from a completed geoprocessing job.
jobInfo.fetchResultMapImageLayer(jobInfo.jobId)).then(function(layer){
view.map.add(layer);
});
Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.
Returns
Type Description * | null | undefined Returns a new instance of this class.Inherited
Method hasHandles(groupKey){Boolean}
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.
Returns true if a named group of handles exist.
Parameter
groupKey *
optionalA group key.
Returns
Type Description Boolean Returnstrue
if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
obj.removeHandles("watch-view-updates");
}
Inherited
Method removeHandles(groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.
Removes a group of handles owned by the object.
Parameter
groupKey *
optionalA group key or an array or collection of group keys to remove.
Example
obj.removeHandles(); // removes handles from default group
obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");
waitForJobCompletion(options){Promise<JobInfo>}
Resolves when an asynchronous job has completed. Optionally job progress can be monitored.
Parameters
Specification
optionalOptions. See properties below for object specifications.
Specification
optionalDefault Value: 1000
The time in millisecond between remote job status requests.
optionalAbortSignal allows for cancelable asynchronous job. If canceled, the promise will be rejected with an error named AbortError
.
Callback function that is called at the specified interval. Use this method to monitor job status and messages.
Returns
Example
// Submit an asynchronous geoprocessing job. Display the remote job status every 1.5 seconds.
// When the job has completed, the output is a MapImageLayer.
const startDate = "1998-01-01 00:00:00";
const endDate = "1998-05-31 00:00:00";
const params = {
query: "(Date >= date '" + startDate + "' and Date <= date '" + endDate + "')"
};
const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot";
submitJob(url, params).then((jobInfo) => {
const jobid = jobInfo.jobId;
console.log("ArcGIS Server job ID: ", jobid);
const options = {
interval: 1500,
statusCallback: (j) => {
console.log("Job Status: ", j.jobStatus);
}
};
jobInfo.waitForJobCompletion(options).then(() => {
const layer = jobInfo.fetchResultMapImageLayer();
map.add(layer);
});
});
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4