<?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: Sample of AMD version Toggle Layer Visibility in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658499#M61413</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, take a look at this &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/101309-ArcGIS-JavaScript-Table-of-Content-%28TOC-checkboxes%29"&gt;thread&lt;/A&gt;&lt;SPAN&gt;, which adds the check boxes dynamically and uses a Legend.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Jan 2014 13:55:56 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2014-01-28T13:55:56Z</dc:date>
    <item>
      <title>Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658494#M61408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a sample out there for this.&amp;nbsp; I tried to convert the legacy version &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/jssamples/map_explicitlayerlist.html"&gt;here&lt;/A&gt;&lt;SPAN&gt; but it wouldn't display or toggle my layer on and off.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 19:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658494#M61408</guid>
      <dc:creator>StevenGraf1</dc:creator>
      <dc:date>2014-01-27T19:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658495#M61409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post your code that you are trying to do this with. I do not think there is anything that you specifically need to require to make this work. You should be able to just get a valid reference to your layer object, and call setVisibleLayers with a valid array of layer id's and it should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 20:01:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658495#M61409</guid>
      <dc:creator>RobertWinterbottom</dc:creator>
      <dc:date>2014-01-27T20:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658496#M61410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I added in &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ImageParameters"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function(...ArcGISDynamicMapServiceLayer, ImageParameters,...)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var layer, map, visible = [];&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;changed...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;//Use the ImageParameters to set the visible layers in the map service during ArcGISDynamicMapServiceLayer construction.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var imageParameters = &lt;STRONG&gt;new esri.layers.ImageParameters();&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imageParameters.layerIds = [0];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; imageParameters.layerOption = &lt;STRONG&gt;esri.layers.ImageParameters.LAYER_OPTION_SHOW;&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //can also be: LAYER_OPTION_EXCLUDE, LAYER_OPTION_HIDE, LAYER_OPTION_INCLUDE

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer =&lt;STRONG&gt; esri.layers.ArcGISDynamicMapServiceLayer&lt;/STRONG&gt;("http://my/MapServer", {"imageParameters":imageParameters});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(layer);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; function updateLayerVisibility() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var inputs = dojo.query(".list_item"), input;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //in this application layer 2 is always on.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible = [0];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i=0, il=inputs.length; i&amp;lt;il; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (inputs&lt;I&gt;.checked) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible.push(inputs&lt;I&gt;.id);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if there aren't any layers visible set the array value to = -1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(visible.length === 0){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible.push(-1);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.setVisibleLayers(visible);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[HTML]&amp;lt;label class="chkLabel"&amp;gt;&amp;lt;input type='checkbox' class='list_item' id='0' value=0 onclick='updateLayerVisibility();'&amp;gt;Interior Space&amp;lt;/label&amp;gt;[/HTML]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:51:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658496#M61410</guid>
      <dc:creator>StevenGraf1</dc:creator>
      <dc:date>2021-12-12T03:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658497#M61411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got it to show but I can't turn it off and on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jan 2014 23:13:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658497#M61411</guid>
      <dc:creator>StevenGraf1</dc:creator>
      <dc:date>2014-01-27T23:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658498#M61412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you put your code at &lt;/SPAN&gt;&lt;A href="http://jsbin.com/"&gt;JS Bin&lt;/A&gt;&lt;SPAN&gt; to show what you've done? I'm suspecting that you have the function "updateLayerVisibility" inside the require statement, where the check boxes cannot get access. Take a look at this &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/100103-Checkbox-onclick-can-not-control-the-function-why"&gt;thread&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jan 2014 12:17:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658498#M61412</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-01-28T12:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658499#M61413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, take a look at this &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/101309-ArcGIS-JavaScript-Table-of-Content-%28TOC-checkboxes%29"&gt;thread&lt;/A&gt;&lt;SPAN&gt;, which adds the check boxes dynamically and uses a Legend.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jan 2014 13:55:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658499#M61413</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-01-28T13:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sample of AMD version Toggle Layer Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658500#M61414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sounds Like what Ken is saying is right, attaching the function to the checkbox inline via the "onclick" attribute will look for a global function by that name.&amp;nbsp; However if you defined that function inside the require statement, it will be scoped to that require and not globally which will probably show some errors in the console when you try to check them.&amp;nbsp; Putting it in JSBin or JSFiddle so we could see the whole code would be really helpful or you can try adding the listeners programmatically via document.addEventListener (or attachEvent depending what browsers you want to support) or just use dojo's on module.&amp;nbsp; It would look something like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
require(["dojo/on", "dojo/dom"], function (on, dom) {
&amp;nbsp; function updateLayerVisibility() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
&amp;nbsp; }&amp;nbsp; 

&amp;nbsp; on(dom.byId("myCheckbox"),"click",updateLayerVisibility);

});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure the modules you require map to your aliases and remember that your aliases are case-sensitive, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
require(["dojo/dom"], function (dom) {
&amp;nbsp; Dom.byId(); // This will fail because its using a capital, 
&amp;nbsp; dom.byId(); // This is the right way
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and if you require dojo/dom, then dojo/on, and in the function parameters you specify them in a different order (on, dom) they will not work as expected, the order must match the order in which they were required.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:51:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/sample-of-amd-version-toggle-layer-visibility/m-p/658500#M61414</guid>
      <dc:creator>RobertWinterbottom</dc:creator>
      <dc:date>2021-12-12T03:51:55Z</dc:date>
    </item>
  </channel>
</rss>

