<?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 Re: Linking MapImageLayer, Sublayers to checkboxes in a sidebar in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238355#M79577</link>
    <description>&lt;P&gt;The problem is that querySelector only returns the first matching element, but you want all matching elements.&amp;nbsp; Instead, you can use querySelectorAll.&amp;nbsp; The last part would then go something like this instead:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        const sublayersElements = document.querySelectorAll(".list_item");
        for (var x = 0; x &amp;lt; sublayersElements.length; x++) {
          sublayersElements[x].addEventListener("click", (event) =&amp;gt; {
            const id = event.target.getAttribute("data-id");
            if (id) {
              const sublayer = layer.findSublayerById(parseInt(id));
              const node = document.querySelector(".list_item[data-id='" + id + "']");
              sublayer.visible = !sublayer.visible;
              node.classList.toggle("visible-layer");
            }
          });
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2022 16:40:30 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2022-12-06T16:40:30Z</dc:date>
    <item>
      <title>Linking MapImageLayer, Sublayers to checkboxes in a sidebar</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238197#M79572</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm currently working with this example to attempt to link MapIMageLayer - Sublayers to checkboxes instead of button divs as per the example&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/layers-mapimagelayer-sublayers/" target="_blank" rel="noopener"&gt;MapImageLayer - Toggle sublayer visibility | Sample Code | ArcGIS API for JavaScript 4.25 | ArcGIS Developers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I can get the first checkbox working but the others are unresponsive. I have simply tried to replicate their code using Li checkbox inputs rather than Button Div inputs&lt;/P&gt;&lt;P&gt;heres a pen of my attempts&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/10ldavis/pen/jOKXgxQ" target="_blank" rel="noopener"&gt;A Pen by Leon (codepen.io)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;any help is really appreciated, it's been a while...&amp;nbsp; :')&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 13:06:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238197#M79572</guid>
      <dc:creator>LeonDavis</dc:creator>
      <dc:date>2022-12-06T13:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Linking MapImageLayer, Sublayers to checkboxes in a sidebar</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238355#M79577</link>
      <description>&lt;P&gt;The problem is that querySelector only returns the first matching element, but you want all matching elements.&amp;nbsp; Instead, you can use querySelectorAll.&amp;nbsp; The last part would then go something like this instead:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;        const sublayersElements = document.querySelectorAll(".list_item");
        for (var x = 0; x &amp;lt; sublayersElements.length; x++) {
          sublayersElements[x].addEventListener("click", (event) =&amp;gt; {
            const id = event.target.getAttribute("data-id");
            if (id) {
              const sublayer = layer.findSublayerById(parseInt(id));
              const node = document.querySelector(".list_item[data-id='" + id + "']");
              sublayer.visible = !sublayer.visible;
              node.classList.toggle("visible-layer");
            }
          });
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 16:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238355#M79577</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-12-06T16:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Linking MapImageLayer, Sublayers to checkboxes in a sidebar</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238660#M79587</link>
      <description>&lt;P&gt;Hi Joel,&lt;/P&gt;&lt;P&gt;Thanks so much for this, that makes sense.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wish you a great week&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 12:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/linking-mapimagelayer-sublayers-to-checkboxes-in-a/m-p/1238660#M79587</guid>
      <dc:creator>LeonDavis</dc:creator>
      <dc:date>2022-12-07T12:01:29Z</dc:date>
    </item>
  </channel>
</rss>

