Geoprocessing - hotspot analysis

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, select a data range and click on the Analyze 911 Calls button. Note the larger the date range, the longer it may take for the task to run and send back the results.

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 a promise which can be used with .then() to define three callbacks:

  1. When the task runs successfully
  2. When the task fails
  3. Gets updates on task execution
var params = {
  Query: buildDefinitionQuery()
};
gp.submitJob(params).then(drawResultData, errBack, progTest);

While the task is executing, the progTest callback pushes updates from the task to the browser console.

function progTest(value){
  console.log(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) {
  // set imageParameters
  var imageParams = new ImageParameters({
    format: "png32",
    dpi: 300
  });

  // Get the task result as a MapImageLayer
  var resultLayer = gp.getResultImageLayer(result.jobId, null, imageParams);
  resultLayer.opacity = 0.7;
  resultLayer.title = "HotspotLayer";

  // add the result layer to the map
  map.layers.add(resultLayer);
}

Sample search results

TitleSample

There were no match results from your search criteria.