<?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 ArcGIS.com template - Layers selection question in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-com-template-layers-selection-question/m-p/473323#M43890</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been modifying the &lt;/SPAN&gt;&lt;STRONG&gt;basic viewer&lt;/STRONG&gt;&lt;SPAN&gt; template project from ArcGIS.com for my own project. The Layer list is created by this function in the layout.js file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
//Create a menu with a list of operational layers. Each menu item contains a check box
//that allows users to toggle layer visibility.
function addLayerList(layers) {
 var layerList = buildLayerVisibleList(layers);
 if (layerList.length &amp;gt; 0) {
&amp;nbsp; //create a menu of layers
&amp;nbsp; layerList.reverse();
&amp;nbsp; var menu = new dijit.Menu({
&amp;nbsp;&amp;nbsp; id : 'layerMenu'
&amp;nbsp; });
&amp;nbsp; dojo.forEach(layerList, function(layer) {
&amp;nbsp;&amp;nbsp; menu.addChild(new dijit.CheckedMenuItem({
&amp;nbsp;&amp;nbsp;&amp;nbsp; label : layer.title,
&amp;nbsp;&amp;nbsp;&amp;nbsp; checked : layer.visible,
&amp;nbsp;&amp;nbsp;&amp;nbsp; onChange : function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (layer.layer.featureCollection) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //turn off all the layers in the feature collection even
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //though only the&amp;nbsp; main layer is listed in the layer list
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(layer.layer.featureCollection.layers, function(layer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.layerObject.setVisibility(!layer.layerObject.visible);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.layer.setVisibility(!layer.layer.visible);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }));
&amp;nbsp; });

&amp;nbsp; var button = new dijit.form.DropDownButton({
&amp;nbsp;&amp;nbsp; label : i18n.tools.layers.label,
&amp;nbsp;&amp;nbsp; id : "layerBtn",
&amp;nbsp;&amp;nbsp; iconClass : "esriLayerIcon",
&amp;nbsp;&amp;nbsp; title : i18n.tools.layers.title,
&amp;nbsp;&amp;nbsp; dropDown : menu
&amp;nbsp; });

&amp;nbsp; dojo.byId('webmap-toolbar-center').appendChild(button.domNode);
 }
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is nothing wrong about this in runtime except the user can really see whatever is last checked in the list of checkboxes. I have been digging for few hours but I cannot find anyway to uncheck the other layers in runtime. I want these checkboxes to behave like Radio Buttons. There is no radio buttons in dijit menu items and I am not in the stage to rewrite this layer selection from scratch. If I give an "id" to the CheckedMenuItem, I can get to it using dojo.byId in runtime. But then none of the .checked, .set("checked", [true/false]), etc. will work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anything I can do?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Nov 2012 17:57:05 GMT</pubDate>
    <dc:creator>HubertLo</dc:creator>
    <dc:date>2012-11-01T17:57:05Z</dc:date>
    <item>
      <title>ArcGIS.com template - Layers selection question</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-com-template-layers-selection-question/m-p/473323#M43890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been modifying the &lt;/SPAN&gt;&lt;STRONG&gt;basic viewer&lt;/STRONG&gt;&lt;SPAN&gt; template project from ArcGIS.com for my own project. The Layer list is created by this function in the layout.js file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
//Create a menu with a list of operational layers. Each menu item contains a check box
//that allows users to toggle layer visibility.
function addLayerList(layers) {
 var layerList = buildLayerVisibleList(layers);
 if (layerList.length &amp;gt; 0) {
&amp;nbsp; //create a menu of layers
&amp;nbsp; layerList.reverse();
&amp;nbsp; var menu = new dijit.Menu({
&amp;nbsp;&amp;nbsp; id : 'layerMenu'
&amp;nbsp; });
&amp;nbsp; dojo.forEach(layerList, function(layer) {
&amp;nbsp;&amp;nbsp; menu.addChild(new dijit.CheckedMenuItem({
&amp;nbsp;&amp;nbsp;&amp;nbsp; label : layer.title,
&amp;nbsp;&amp;nbsp;&amp;nbsp; checked : layer.visible,
&amp;nbsp;&amp;nbsp;&amp;nbsp; onChange : function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (layer.layer.featureCollection) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //turn off all the layers in the feature collection even
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //though only the&amp;nbsp; main layer is listed in the layer list
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(layer.layer.featureCollection.layers, function(layer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.layerObject.setVisibility(!layer.layerObject.visible);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.layer.setVisibility(!layer.layer.visible);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }));
&amp;nbsp; });

&amp;nbsp; var button = new dijit.form.DropDownButton({
&amp;nbsp;&amp;nbsp; label : i18n.tools.layers.label,
&amp;nbsp;&amp;nbsp; id : "layerBtn",
&amp;nbsp;&amp;nbsp; iconClass : "esriLayerIcon",
&amp;nbsp;&amp;nbsp; title : i18n.tools.layers.title,
&amp;nbsp;&amp;nbsp; dropDown : menu
&amp;nbsp; });

&amp;nbsp; dojo.byId('webmap-toolbar-center').appendChild(button.domNode);
 }
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is nothing wrong about this in runtime except the user can really see whatever is last checked in the list of checkboxes. I have been digging for few hours but I cannot find anyway to uncheck the other layers in runtime. I want these checkboxes to behave like Radio Buttons. There is no radio buttons in dijit menu items and I am not in the stage to rewrite this layer selection from scratch. If I give an "id" to the CheckedMenuItem, I can get to it using dojo.byId in runtime. But then none of the .checked, .set("checked", [true/false]), etc. will work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anything I can do?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2012 17:57:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-com-template-layers-selection-question/m-p/473323#M43890</guid>
      <dc:creator>HubertLo</dc:creator>
      <dc:date>2012-11-01T17:57:05Z</dc:date>
    </item>
  </channel>
</rss>

