AnsweredAssumed Answered

Access results on a Deferred object on identifyTask

Question asked by endlessdsire on Mar 3, 2017
Latest reply on Mar 3, 2017 by rscheitlin


I have an app where i need to save the results on a custom array. They come from the deferred identify task when an user clicks on the map.


I have the following:


  mapp.on('click', (event)=>{

      var identifyTask, identifyParams;

      identifyTask = new IdentifyTask(layers.read_dynamic_ap());
      identifyParams = new IdentifyParameters();
      identifyParams.tolerance = 10;
      identifyParams.returnGeometry = true;
      identifyParams.layerIds = [0, 1];
      identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
      identifyParams.width = mapp.width;
      identifyParams.height = mapp.height;
      identifyParams.geometry = event.mapPoint;
      identifyParams.mapExtent = mapp.extent;

      var deferred = identifyTask
        .addCallback(function (response){
          return, function (result) {
                          var feature = result.feature;
                          var layerName = result.layerName;

                          feature.attributes.layerName = layerName;

                          if(layerName === 'Cars'){
                            var carsTemplate= new InfoTemplate("ID: ${id}",
                              "Car: ${car} <br />" +
                              "Type: ${type}<br /> ");
                          return feature;
      //see content :
      console.log("hello def", deferred.results);


In the same point could be more than 1 result, so i want to save them all in a custom array made for me for special purposes.


When i see the content coming for that deferred var i have this:

  console.log("hello def", deferred);

Where i can see there is a property called results (its an array).

I tried to put in console.log(deferred.results) but i get undefined.


There is a way how to save those results? What im doing wrong?


Thanks in advice.