AnsweredAssumed Answered

Problems with IdentifyTask

Question asked by sl5337 on Sep 27, 2018
Latest reply on Sep 28, 2018 by sl5337

I've already spent an entire day trying to figure this out and I've gotten nowhere.  I've implemented functionality that allows the user to draw a polygon and identify features within that polygon.  I'm using SketchViewModel for the polygon and listening to the "create-complete" event to get the geometry and execute the IdentifyTask.  


The problem is that the IdentifyTask returns ALL features within the polygon, not just the ones I specify in the layerIds property.  That includes features from hidden layers, even though I have specified to only return visible features.  Here is the relevant part of my code.


const identifyTask = new IdentifyTask(mapServiceUrl);

let params = new IdentifyParameters();
params.tolerance = 3;
params.layerIds = layerIds;
params.layerOption = "visible";
params.width = view.width;
params.height = view.height;
params.returnGeometry = true;
params.geometry = event.geometry;
params.mapExtent = view.extent;

identifyTask.execute(params).then(function (response) {
    const results = response.results;
   // process the results....

So assume that my layerIds value is [40].  The IdentifyTask returns features from ALL sublayers of the map service identified by
mapServiceUrl.  In this case the map service has sublayers with id's 39,40,41,42 and 43. The results of the IdentifyTask contain
features from ALL of those layers. What's more, each result coming back from IdentifyTask is assigned layer id 40 and the layer
name of the layer with id 40. Further experimentation showed that if I specify more than one layer id in my layerIds property,

such as [39,40] the IdentifyTask still returns features from all five sublayers and assigns each one a layer id of 39 and a layer name
matching the name of layer 39. So the first layer id and layer name gets assigned to all of the results coming back, regardless of which
layer the feature came from.

I'm obviously doing something drastically wrong here but I just don't see it. I've followed the documentation and played with the
sandbox example, but the one example is so different from what I'm trying to do I can't simulate this same situation.

The only other information I can think of to provide is that I'm using version 4.8 of the JavaScript API and version 10.2 of ArcGIS server.
Also, I'm rendering my map services as MapImageLayer components if that is relevant.

Hopefully someone can point me in the right direction.