3

I'm using ArcGIS Javascript API, and I need to query the GIS and show the results on the map. Currently I have used a Query Task by specifying the layer, the "where" statement, graphic symbol, InfoTemplate etc. and it works well. I'm wondering however whether I should be using a FeatureLayer with a Definition Expression, rather than the Query Task. Using a Feature Layer would enable the drawing information from the server to be used. Also the symbol would show in the legend. When is it better to use a Query Task rather then a Feature Layer?

1

Using a FeatureLayer cuts down on the amount of code you would write, simply by setting its mode or setting a definition expression. Moreover, like you said, the symbology comes through.

A query layer is useful when you want to get a set of records back based on a where clause or by geometry. You could use a geometry as an input to query a layer.

I would compare the QueryTask with IdentifyTask since they are more similar. The IdentifyTask does not allow you to pick which fields to output, but you can select the layers you would like to identify.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.