<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Identifyparameters not working with layerids even with proposed fix in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifyparameters-not-working-with-layerids-even/m-p/1153000#M76625</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I know there's a bug with 4.22's implementation of layerIds in IdentifyParameters but even with the proposed &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/identify-not-honoring-layerids-supplied-to/m-p/1137516#M76101" target="_self"&gt;fix here&lt;/A&gt;&amp;nbsp;, I'm still not seeing the results I'd expect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see my code below. mapServiceUrlList is an array of objects with { url, layerIds[] }. On map click I want to get all results from the identify. If I hard code layerIds outside of the forEach block with the array it works as intended, but if it's within the forEach dynamically generated it doesn't work. Any help is appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let params = new IdentifyParameters({
    tolerance: 5,
    layerOption: "all",
    returnGeometry: true,
    spatialReference: view.spatialReference,
    geometry: mapPoint,
    width: view.width,
    height: view.height,
    mapExtent: view.extent,
  });

const mapServiceUrlList = getMapServiceUrls();
  mapServiceUrlList.forEach(({ url, layerIds }) =&amp;gt; {
    params.layerIds = layerIds;
    params.sublayers = [{ id: params.layerIds }];
    identify.identify(url, params).then(({ results }) =&amp;gt; {
      if (results.length &amp;gt; 0) console.log(results);
    });
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: I found if I declare a new IdentifyParameters object with every iteration of the forEach it works as intended, otherwise it just runs properly on the first object iterated. See my fix here:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const mapServiceUrlList = getMapServiceUrls();
  mapServiceUrlList.forEach(({ url, layerIds }) =&amp;gt; {
    let params = new IdentifyParameters({
      tolerance: 5,
      layerOption: "visible",
      returnGeometry: true,
      spatialReference: view.spatialReference,
      geometry: mapPoint,
      width: view.width,
      height: view.height,
      mapExtent: view.extent,
      layerIds,
    });
    params.sublayers = [{ id: params.layerIds[0] }];
    identify.identify(url, params).then(({ results }) =&amp;gt; {
      if (results.length &amp;gt; 0) console.log(results);
    });
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Mar 2022 18:40:01 GMT</pubDate>
    <dc:creator>succip</dc:creator>
    <dc:date>2022-03-11T18:40:01Z</dc:date>
    <item>
      <title>Identifyparameters not working with layerids even with proposed fix</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifyparameters-not-working-with-layerids-even/m-p/1153000#M76625</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I know there's a bug with 4.22's implementation of layerIds in IdentifyParameters but even with the proposed &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/identify-not-honoring-layerids-supplied-to/m-p/1137516#M76101" target="_self"&gt;fix here&lt;/A&gt;&amp;nbsp;, I'm still not seeing the results I'd expect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see my code below. mapServiceUrlList is an array of objects with { url, layerIds[] }. On map click I want to get all results from the identify. If I hard code layerIds outside of the forEach block with the array it works as intended, but if it's within the forEach dynamically generated it doesn't work. Any help is appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let params = new IdentifyParameters({
    tolerance: 5,
    layerOption: "all",
    returnGeometry: true,
    spatialReference: view.spatialReference,
    geometry: mapPoint,
    width: view.width,
    height: view.height,
    mapExtent: view.extent,
  });

const mapServiceUrlList = getMapServiceUrls();
  mapServiceUrlList.forEach(({ url, layerIds }) =&amp;gt; {
    params.layerIds = layerIds;
    params.sublayers = [{ id: params.layerIds }];
    identify.identify(url, params).then(({ results }) =&amp;gt; {
      if (results.length &amp;gt; 0) console.log(results);
    });
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: I found if I declare a new IdentifyParameters object with every iteration of the forEach it works as intended, otherwise it just runs properly on the first object iterated. See my fix here:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const mapServiceUrlList = getMapServiceUrls();
  mapServiceUrlList.forEach(({ url, layerIds }) =&amp;gt; {
    let params = new IdentifyParameters({
      tolerance: 5,
      layerOption: "visible",
      returnGeometry: true,
      spatialReference: view.spatialReference,
      geometry: mapPoint,
      width: view.width,
      height: view.height,
      mapExtent: view.extent,
      layerIds,
    });
    params.sublayers = [{ id: params.layerIds[0] }];
    identify.identify(url, params).then(({ results }) =&amp;gt; {
      if (results.length &amp;gt; 0) console.log(results);
    });
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 18:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifyparameters-not-working-with-layerids-even/m-p/1153000#M76625</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2022-03-11T18:40:01Z</dc:date>
    </item>
  </channel>
</rss>

