Chapter 7. Finding, Querying, and Identifying Features

When users use your app, they are using it to retrieve information by specifying some criteria or clicking on the map/scene, and then expecting some kind of result that either provides them with the information they asked for, or lets them know that nothing was found. In this chapter, we're going to turn our attention to retrieving information from the layers we've been using so that our users can quickly and easily get information out of the app. In particular, we're going to discuss the options available in ArcGIS Runtime that allow us to find, query, and identify features in a FeatureLayer resource. We're also going to discuss the difference between Find, Query, and Identify, how tasks are relevant to this discussion, and how to implement these tasks following the MVVM pattern. We will also discuss the following topics:

  • Tasks
  • Finding features
  • Attributes and spatial queries
  • Identify

Tasks

Everything you will be using in this chapter will be related to the .NET concept of tasks. Tasks were introduced in .NET Framework 4 and have greatly simplified the process of writing asynchronous applications, which makes your apps more responsive and non-blocking. A user can enter some search parameter, such as a name, press a button or hit the Enter key, and then the operation will do its work in such a manner that it doesn't prevent the user from continuing to work on other parts of the app. ArcGIS Runtime's capabilities are heavily based on this pattern, so it's important that you have a good understanding of how to execute code using this pattern.

In this chapter, we're going to explore Esri.ArcGISRuntime.Tasks. This namespace has many classes in it, but for now we're going to just focus on the ones relevant to the topic of this chapter. In later chapters, we'll return to this namespace because the pattern of using tasks is so prevalent when using ArcGIS Runtime. In Esri.ArcGISRuntime.Tasks, you'll find the following classes:

Tasks

The TaskBase class is a base class that has two properties: ServiceUri and Token. The FindTask, QueryTask and IdentifyTask constructors inherit from TaskBase. To use these tasks, we will generally follow this pattern:

  1. Instantiate the task using an online or local resource such as FeatureService or FeatureLayer.
  2. Provide the task with the necessary parameters for it to operate. Without some parameters, the task won't return what you need, so this is a necessary step.
  3. Now that you have a task and the provided parameters, execute the task.
  4. Execute the task using a method such as ExecuteAsync, and then do something with the results, such as show the user a list, generate a new geometry, and then display it as a graphic, and send the results to another ViewModel as part of the input to another tool.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.17.139