Identify not honoring layerIds supplied to IdentifyParameters

794
3
Jump to solution
01-07-2022 04:10 AM
Ranga_Tolapi
Occasional Contributor III

Refer to the Esri sample https://developers.arcgis.com/javascript/latest/sample-code/identify/live/. which is based on import * as identify from "@arcgis/core/rest/identify";

In the above sample, change the line number 70.

 

From:
params.layerIds = [0, 1, 2, 3, 4];
To:
params.layerIds = [0];

 

Actually, layer id 0 represents Roads layer. After the above code change, Identify should work only on Road layer, but it's not the case here.

Additional observation is, for payload of the network transaction, could not see the provided layer ids at all. Refer to the below screenshot.

Ranga_Tolapi_0-1641556931003.png

 

0 Kudos
2 Solutions

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Hi @Ranga_Tolapi, this is a known issue that will be fixed at the next release (4.23). It should also be ready to test on next soon: https://github.com/Esri/feedback-js-api-next

 

View solution in original post

0 Kudos
JoelBennett
MVP Regular Contributor

This bug in 4.22 is related to the new IdentifyParameters.sublayers property added in 4.22.  The way they've implemented it, layerIds will be ignored if you do not supply a value for sublayers.  Nonetheless, this is very easy to work around if you don't want to wait until 4.23 is released.

If you're identifying against a MapImageLayer, as is the case in the sample, you can simply set the IdentifyParameters instance's sublayers property to the MapImageLayer instance's sublayers property.  In this case, I did this on line 85:

        // Executes each time the view is clicked
        function executeIdentify(event) {
          // Set the geometry to the location of the view click
          params.sublayers = identifyLayer.sublayers; //added line
          params.geometry = event.mapPoint;
          params.mapExtent = view.extent;

 

Technically, to make this work as desired, all that's required is to at minimum supply an array containing a single object having an "id" property that matches a value in what you're supplying for layerIds:

        // Executes each time the view is clicked
        function executeIdentify(event) {
          // Set the geometry to the location of the view click
          params.sublayers = [{id:params.layerIds[0]}]; //added line
          params.geometry = event.mapPoint;
          params.mapExtent = view.extent;

 

View solution in original post

3 Replies
Noah-Sager
Esri Regular Contributor

Hi @Ranga_Tolapi, this is a known issue that will be fixed at the next release (4.23). It should also be ready to test on next soon: https://github.com/Esri/feedback-js-api-next

 

0 Kudos
JoelBennett
MVP Regular Contributor

This bug in 4.22 is related to the new IdentifyParameters.sublayers property added in 4.22.  The way they've implemented it, layerIds will be ignored if you do not supply a value for sublayers.  Nonetheless, this is very easy to work around if you don't want to wait until 4.23 is released.

If you're identifying against a MapImageLayer, as is the case in the sample, you can simply set the IdentifyParameters instance's sublayers property to the MapImageLayer instance's sublayers property.  In this case, I did this on line 85:

        // Executes each time the view is clicked
        function executeIdentify(event) {
          // Set the geometry to the location of the view click
          params.sublayers = identifyLayer.sublayers; //added line
          params.geometry = event.mapPoint;
          params.mapExtent = view.extent;

 

Technically, to make this work as desired, all that's required is to at minimum supply an array containing a single object having an "id" property that matches a value in what you're supplying for layerIds:

        // Executes each time the view is clicked
        function executeIdentify(event) {
          // Set the geometry to the location of the view click
          params.sublayers = [{id:params.layerIds[0]}]; //added line
          params.geometry = event.mapPoint;
          params.mapExtent = view.extent;

 

Ranga_Tolapi
Occasional Contributor III

Thank you @JoelBennett, your workaround worked like a charm 👍

0 Kudos