<?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: Setting Default Visibility in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45759#M3996</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;So, I'm curious as to how I can set the "default visibility" property of a layer in a map to "false", so that the checkbox I create for it is unchecked from the beginning.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a guess, but may need to do this in ArcMap, so that the MXD/MSD uses this setting to create the map service with that visibility hard-coded?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;For reference, I'm looking at this sample:&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm&lt;/A&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To provide the full link to the sample, you need to right-click on the sample's name and choose Copy Link Address, or Open In New Tab. Otherwise the homepage is shown.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jul 2011 00:55:45 GMT</pubDate>
    <dc:creator>StephenLead</dc:creator>
    <dc:date>2011-07-12T00:55:45Z</dc:date>
    <item>
      <title>Setting Default Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45755#M3992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm attempting to create a list of checkboxes for the user to toggle the visibility of feature layers in a dynamic map service layer. I want to start the application with one feature layer visible, while the others remain off.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The sample shown here: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...uses the 'layer.layerInfos.defaultVisibility' property to determine which checkboxes are turned on from the start.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even though I use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;layers = new esri.layers.ArcGISDynamicMapServiceLayer("http://server/ArcGIS/rest/services/features/MapServer"
&amp;nbsp; );
&amp;nbsp; layers.setVisibleLayers([0])
 }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...to set the initial visibility, that doesn't alter the default visibility property for the other feature layers, so the sample script doesn't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anybody know how to adjust this property?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DR&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:47:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45755#M3992</guid>
      <dc:creator>DuncanRager</dc:creator>
      <dc:date>2021-12-10T21:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Default Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45756#M3993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to wait for your layer to load before you can call setVisibleLayers. Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://server/ArcGIS/rest/services/features/MapServer");
dojo.connect(layer, 'onLoad', function(l) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; l.setVisibleLayers([1]);
});&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45756#M3993</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-10T21:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Default Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45757#M3994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which sample you are referring to? Is this one?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 16:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45757#M3994</guid>
      <dc:creator>SiqiLi</dc:creator>
      <dc:date>2011-07-07T16:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Default Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45758#M3995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As you say, setting the visible layers as an event handler of the layer load works... however for the script below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function buildLayerList(layer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var items = dojo.map(layer.layerInfos,function(info,index){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (info.defaultVisibility) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible.push(info.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; return "&amp;lt;input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id + "' onclick='updateLayerVisibility();' /&amp;gt;&amp;lt;label for='" + info.id + "'&amp;gt;" + info.name + "&amp;lt;/label&amp;gt;";
&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; dojo.byId("layer_list").innerHTML = items.join();

&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;&amp;nbsp;&amp;nbsp; map.addLayer(layer);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...setting the .setVisibleLayers([]) method doesn't change anything about whether the checkbox is checked. It reads the "default visibility" property of each feature layer in the map and applies a "check" in its box from the start if it is set to "true". And even when I use .setVisibleLayers([0]) to only show the first featureclass in the map, all of the layers have a "default visibility" of "true"... this is confirmed with variable watcher in the Firefox extension Firebug. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I'm curious as to how I can set the "default visibility" property of a layer in a map to "false", so that the checkbox I create for it is unchecked from the beginning.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason I need this is because I present the user with 10-15 feature layer checkboxes in a single map service, and If they were all checked from the start, it would be majorly slow, and also show a very cluttered map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For reference, I'm looking at this sample:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45758#M3995</guid>
      <dc:creator>DuncanRager</dc:creator>
      <dc:date>2021-12-10T21:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Default Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45759#M3996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;So, I'm curious as to how I can set the "default visibility" property of a layer in a map to "false", so that the checkbox I create for it is unchecked from the beginning.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just a guess, but may need to do this in ArcMap, so that the MXD/MSD uses this setting to create the map service with that visibility hard-coded?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;For reference, I'm looking at this sample:&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm&lt;/A&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To provide the full link to the sample, you need to right-click on the sample's name and choose Copy Link Address, or Open In New Tab. Otherwise the homepage is shown.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 00:55:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45759#M3996</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2011-07-12T00:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Default Visibility</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45760#M3997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You were right about setting it in the MXD, thank you. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've run into one more issue... this piece of code...:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function addChecklist(fLayers){
&amp;nbsp; var items = dojo.map(fLayers.layerInfos, function(info,index){
&amp;nbsp;&amp;nbsp; if (info.defaultVisibility) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; visible.push(info.id);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; return "&amp;lt;input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" +
&amp;nbsp;&amp;nbsp;&amp;nbsp; info.id + "' onclick='updateLayerVisibility();' /&amp;gt;&amp;lt;label for='" + info.id + "'&amp;gt;" + info.name + "&amp;lt;/label&amp;gt;" + "&amp;lt;br /&amp;gt;"; 
&amp;nbsp; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...doesn't exactly work because no matter what value I've set for the &amp;lt;checked= &amp;gt; attribute of the &amp;lt;input&amp;gt; object, it sees it as true. From my testing, simply have the &amp;lt;checked&amp;gt; attribute in the &amp;lt;input&amp;gt; tag at all sets the default value to 'checked'... so for instance these two lines are the same, resulting in a checked box from the start:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[HTML]&amp;lt;input type='checkbox' class='list_item' id="a" checked="checked"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;input type='checkbox' class='list_item' id="b" checked=""/&amp;gt;[/HTML]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know if there is a value that can be set in the &amp;lt;checked&amp;gt; attribute so that the default is set to not being checked?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DR&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: I skirted the issue with the code below, but I'm still interested to know if there's an value that would set the checked to false.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function addChecklist(fLayers){
&amp;nbsp; var items = dojo.map(fLayers.layerInfos, function(info,index){
&amp;nbsp;&amp;nbsp; if (info.defaultVisibility) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible.push(info.id);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "&amp;lt;input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" +
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; info.id + "' onclick='updateLayerVisibility();' /&amp;gt;&amp;lt;label for='" + info.id + "'&amp;gt;" +&amp;nbsp; info.name + "&amp;lt;/label&amp;gt;" + "&amp;lt;br /&amp;gt;";
&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; return "&amp;lt;input type='checkbox' class='list_item' id='" +
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; info.id + "' onclick='updateLayerVisibility();' /&amp;gt;&amp;lt;label for='" + info.id + "'&amp;gt;" + info.name + "&amp;lt;/label&amp;gt;" + "&amp;lt;br /&amp;gt;";
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:47:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-default-visibility/m-p/45760#M3997</guid>
      <dc:creator>DuncanRager</dc:creator>
      <dc:date>2021-12-10T21:47:20Z</dc:date>
    </item>
  </channel>
</rss>

