2

For fetching data from a feature layer, I've been using QueryTask service,

    var deferred = new Deferred();
    var queryTask = new QueryTask(featureLayerurl)
    var query = new Query();
     query.geometry = geometry;        
    query.where = "document='100'";
    query.returnGeometry = true;
    query.outFields = ["*"];

    return deferred = queryTask.execute(query).addErrback(function (response) {
        console.error(response);
        return null;
    }).addCallback(function (response) {
        return response;
    }).then(function (response) {
        return response;
    });

But recently, I've found that there is dedicated method in FeatureLayer class called queryFeatures for for fetching data.

var query = new esri.tasks.Query();
query.objectIds = [features[0].attributes.OBJECTID];
query.outFields = [ "*" ];
// Query for the features with the given object ID
featureLayer.queryFeatures(query, function(featureSet) {
});

So ,

  1. Is there any difference between when using QueryTask over queryFeatures?

  2. Any kind a of performance difference ?

  3. Do queryFeautres is using QueryTask internally ?

1

To answer your three questions:

  1. Yes.
  2. Yes (for most use cases).
  3. No.

QueryTask is the older/original way - available since the initial version 1.0 and originally the only way. At version 2.0, FeatureLayer was added. This removed the need for using the QueryTask+GraphicsLayer combo in many use cases. There still a few valid use cases for it, but in general you're better off using the FeatureLayer (and its queryFeatures() method). https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#queryfeatures

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.