Select to view content in your preferred language

QueryTask vs. IdentifyTask

1935
2
02-26-2013 05:35 AM
MattFancher
Deactivated User
I'm curious if I should use a QueryTask or an IdentifyTask.  I have a simple JS API map with an ArcGISDynamicMapServiceLayer over a basemap.  I want to display several attributes from a single layer in the dynamic service in an InfoWindow.  I can accomplish that with either a QueryTask or IdentifyTask, right?  Is there a best practice?  Can anyone suggest some pros and cons?  Thanks!
0 Kudos
2 Replies
DianaBenedict
Frequent Contributor
I would say the biggest difference is that Query Task operates on 1 layer in your service and "selects" the records that match your query.  Where as an identify Task can be set up to select from multiple layers in your service and will simply return the records without actually "selecting" them. 

As for performance, I do not know. Generally I use the Query task only because I am dealing with editing the records and I must select them inorder to perform any edits (since this is the way I have set up my FeatureLayer service).

Eventhough you are only dealing with 1 layer, you may want to use the Identify Task since it can easily be implemented to select from multiple layers within your service should the need arise.  Also, the layer options seem very useful as well such as specifying if you want to identify from ALL layers, top most layer or Visible layers only.

Unless you see a performance issue or have a need to perform advance Selection queries (Query Task), it seems like the identify task should do what you need and allow you to add additional functionality as needed.  My two cents...
0 Kudos
TracySchloss
Honored Contributor
I almost always use QueryTask, because I want to format the content of the infoWindow specific to the attributes that are available for a particular layer.  You'll notice in the identify examples that they generically format that content based on all the fields that are available in a layer and you end up with something that works for all, but isn't very nice looking.
0 Kudos