AnsweredAssumed Answered

How do i remove an event listener from Identify Task

Question asked by Steffi_Naico on Sep 14, 2020
Latest reply on Sep 16, 2020 by manishpatelesriaustralia-com-au-esridist

Seems like this should be simple, but I'm stumped. i need the functionality to be done in such a a way that on button click the identify task should be run properly on every click function on map . and on the same time when i press the same button again it should stop the API calls, and the event should be removed and vice-versa. how do it can be possible?



var identifyButton = dom.byId("identify")
on(identifyButton"click"function (evt) {

    //create identify tasks and setup parameters
    identifyTask = new IdentifyTask(textbox.value);

    identifyParams = new IdentifyParameters();
    identifyParams.tolerance = 3;
    identifyParams.returnGeometry = true;
    identifyParams.layerIds = [02];
    identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
    identifyParams.width = map.width;
    identifyParams.height = map.height;
  function executeIdentifyTask(event) {
    identifyParams.geometry = event.mapPoint;
    identifyParams.mapExtent = map.extent;

    var deferred = identifyTask
      .addCallback(function (response) {
        // response is an array of identify result objects
        // Let's return an array of features.
        return (result) {
          var feature = result.feature;
          var layerName = result.layerName;

          feature.attributes.layerName = layerName;
              var Templates = new InfoTemplate("");

              return feature;

    // InfoWindow expects an array of features from each deferred
    // object that you pass. If the response from the task execution
    // above is not an array of features, then you need to add a callback
    // like the one above to post-process the response and return an
    // array of features.