Viewshed sample

Complexity: Intermediate Data Requirement: ArcGIS.com

This sample demonstrates the use of the Geoprocessor task to calculate a viewshed within a five mile distance of an area of interest. It also illustrates how to use an Android AsyncTask to execute asynchronous GP tasks. The application prompts the user to add a point to the map with a single tap on the device, which runs a geoprocessing task to calculate the viewshed.

new link

Sample design

The sample's Activity class sets up the map to include a graphics layer for displaying the results and also adds a single tap listener so the user's map click is captured as the point of interest. An OnClickListener is also added to the Go button so that once a point on the map has been added, it invokes the GP task via the start() method. A progress bar shows to the user until the GP task is complete. If the GP task takes too long to complete, the user is prompted with a message and the progress bar exits.

The AsyncTask class handles the long running asynchronous call to the ArcGIS server GP service in the doInBackground() method, and deals with the results on the user interface (UI) thread in the onPostExecute() method.

Using the sample

Steps:
  1. Load the sample on your device.
  2. Single tap to add a point.
  3. Click the Go button.
  4. View the results when the progress bar is done.
  5. Click the Trash can to clear results.
5/31/2012