You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.
Skip To ContentArcGIS for DevelopersSign In Dashboard

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to execute the Geoprocessor asynchronously to calculate a hotspot analysis based on the frequency of 911 calls. It calculates the frequency of these calls within a given study area during a specified constrained time period set between 1/1/1998 and 5/31/1998. To run the hotspot analysis, click on the Analyze 911 Calls button.

How it works

When the Analyze 911 Calls button is clicked, an event listener triggers the function findHotspot(), which accesses the user-defined dates and passes it as a parameter to the Geoprocessor task. The submitJob() method is subsequently called and performs the task asynchronously. This method returns immediately after the job is submitted with a JobInfo object that contains information relating to the state of the execution of the Geoprocessor task. The waitForJobCompletion() function recognizes when the task has finished processing, then calls the function to draw the result on the map.

var params = {
  Query: buildDefinitionQuery()
  var options = {
    statusCallback: function(jobInfo1){
  gp.waitForJobCompletion(jobInfo.jobId, options).then(function(jobInfo2){

While the task is executing, the progTest function pushes updates from the task to the browser console and the sidebar div.

function progTest(value) {
  message.innerText = "Job status: " + "'" + value.jobStatus + "'";

The drawResultData callback function obtains the task result as a MapImageLayer when the task completes successfully. It then adds the MapImageLayer to the map.

function drawResultData(result) {
  // get the task result as a MapImageLayer
    resultLayer.opacity = 0.7;
    resultLayer.title = "HotspotLayer";

    // add the result layer to the map

Sample search results