IdentifyTask returns empty array

559
8
05-25-2022 02:19 AM
by Anonymous User
Not applicable

I am trying to get the graphics & objectid of a point on the map and am using the identifyTask. I am following this example. This is my code

this.map.on("click", function (e) {
                    _this.map.graphics.clear();

                    identifyTask = new IdentifyTask("https://server/arcgis/rest/services/MUNICIPALITY_BUNDLE/ZK_KATASTAR_NA_ZELENILO/MapServer");

                    identifyParams = new IdentifyParameters();
                    identifyParams.tolerance = 3;
                    identifyParams.returnGeometry = true;
                    identifyParams.layerIds = [0, 2];
                    identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
                    identifyParams.width = _this.map.width;
                    identifyParams.height = _this.map.height;


                    identifyParams.geometry = e.mapPoint;
                    identifyParams.mapExtent = _this.map.extent;
                    console.log("identifyParams", identifyParams);

                    identifyTask.execute(identifyParams, function (idResults) {
                        console.log("test", idResults);
                    });
                });

idResults returns an empty array and I am unsure as to why.

NovicaJ_0-1653470283753.png

Any ideas or pointers as to what I am doing wrong?

0 Kudos
8 Replies
KenBuja
MVP Esteemed Contributor

Try setting the spatial reference to see if that makes any difference.

identifyParams.spatialReference = _this.map.spatialReference;

 

0 Kudos
by Anonymous User
Not applicable

It's still the same.

NovicaJ_0-1653489746172.png

 

0 Kudos
KenBuja
MVP Esteemed Contributor

Are the layerIds you're setting correct? Can you share the URL you're using to verify the process?

0 Kudos
by Anonymous User
Not applicable

@KenBuja 

Here are the layers

NovicaJ_0-1653501727257.png

 

0 Kudos
KenBuja
MVP Esteemed Contributor

Then you'll want to modify this line since there is no layer 0. Your IdentifyTask would only include what is found is Layer 2. Include the layer ids you want to identify.

identifyParams.layerIds = [0, 2];

.

0 Kudos
by Anonymous User
Not applicable
identifyParams.layerIds = [1];
identifyParams.layerIds = [1, 2];

I have made both of these modifications. For a fact, I know that the layer 1 has records in it and it still returns an empty array. 

0 Kudos
by Anonymous User
Not applicable

NovicaJ_0-1653513414283.png

Whether I include all of the layers as above, or just one single layer it still returns an empty array.

0 Kudos
RobertMEIER
Occasional Contributor

try changing you layerOption value, the documentation says it should be a string, either "top", "visible" or "all".

0 Kudos