Identifying Features on the Map

An Identify is a user driven operation typically involving a single click on the map and the retrieval of information about any features hit by that click point from any layer in the map. This operation has the potential to retrieve a lot of information depending on the Identify parameters specified. In the ArcGIS Runtime SDK for WPF you can use the Identify task, to search the layers in both local and online data for features that intersect an input geometry. Once the matching features are returned, you can display their geometries and attributes in your WPF application.

User Interface

The Identify task does not specify the user interface, therefore implementation is required to allow the users to define the user input and display the geometries and attributes of the results in the WPF application. The best practice is to separate an application's presentation layer from its business logic. In WPF, XAML is intended to house the presentation layer, while the code-behind is for an application's business logic. There are numerous ways in which the user input to the operation can be provided through the interface of your WPF application. It might be by defining the geographic coordinates by a map click or selecting geographic coordinates from a textbox or listbox. To display the Identify task's results you need to specify an output interface and organizing the results in a small space can be a challenge. The result features of an Identify operation will often overlap geographically and to enable users to view and select the feature required one good solution is a WPF ComboBox control to display the multiple features, combined with a WPF DataGrid control to display the attributes for each selected feature and a GraphicsLayer to display the selected feature's geometry on the map.

Using the Identify task with online data

To perform Identify operations on online data in your WPF application you will need to pass the URL of an online service or layer. To find the URL, you can use the ArcGIS Services Directory. An example is below(example in C#):

Declare and instantiate an Identify task. Set the map service so that the task will search by passing the service's URL to the Identify task's constructor.

IdentifyTask identifyTask = new 
IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
		"Demographics/ESRI_Census_USA/MapServer");

Using the Identify task with local data

To perform Identify operations on local data in your WPF application you will need to consume the Identify task programmatically with the following steps (example in C#):

Create and Initialize a new LocalMapService with the path to an ArcGIS map package. In this example we are using the StartAsync method to start the local map service and handling the StartCompleted callback inline with a Lambda Expression.

LocalMapService localMapService = new LocalMapService(@"Path to ArcGIS map package");
localMapService.StartAsync(delegateService =>
{
    // ...
});

Declare and instantiate the Identify task class and set the Url property to that of the local map service Url. In contrast to the Query task which operates on a single layer within a service, the Identify task can operate on all layers within a service.

LocalMapService localMapService = new LocalMapService(@"Path to ArcGIS map package");
localMapService.StartAsync(delegateService =>
{
    IdentifyTask identifyTask = new IdentifyTask();
    identifyTask.Url = localMapService.UrlMapService;
});

Identify parameters

Before using Identify operations you will need to define the operation's input parameters. These parameters will vary depending on the operation. The IdentifyParameters object is used to specify the input for the Identify task. You can customize your Identify operation by specifying Identify parameters such as LayerIds to narrow down the amount of data you see by filtering the layers you are interested in. The LayerOption parameter can also be set to search only the top-most or visible layers. By reducing the number of layers Identify works with, you can quickly focus on what is important to you. The geometry Identify parameter allows you to specify a geometry to perform an Identify on, this enables the flexibility of identify areas such as polygons, envelopes and polylines as well as points.

1/27/2015