<?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: setVisibleLayers to a function  in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739364#M68440</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Not likely, The only way I can think that this would work is if you add the map object with not layers and then once the layer list is done getting the layer visibility from the database then have a function that will add the map layers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am really unsure of how you are attempting to use setVisibleLayers function here...&lt;/P&gt;&lt;P&gt;roadLayer.setVisibleLayers([$('#ulLayerVisibility input[type="checkbox"]:checked').map(function ()&lt;/P&gt;&lt;P&gt;setVisibleLayers function takes an array of layer ids.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jan 2016 03:31:52 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2016-01-28T03:31:52Z</dc:date>
    <item>
      <title>setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739363#M68439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I dynamically create a listview based on data from SQL server, which lists maps layers and visibility. I can loop through list to create array or visible layers. This works great when I make a change in the listview but I would like to use the process to setVisibleLayers when the map is loaded. I am trying to set the setVisibleLayers method of layer to the same .get function I use elsewhere but the layers are not visible. I believe it is because listview has not been fully created yet. Is there a way I can set the visible layers this way?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var roadLayer = new esri.layers.ArcGISDynamicMapServiceLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fgisappserv3.spokanecounty.org%2FArcGIS%2Frest%2Fservices%2FEngineering%2FENGINEERINGqueries_10%2FMapServer" rel="nofollow" target="_blank"&gt;http://gisappserv3.spokanecounty.org/ArcGIS/rest/services/Engineering/ENGINEERINGqueries_10/MapServer&lt;/A&gt;&lt;SPAN&gt;", &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{ id: "roadLayer",&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; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;visible: true&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; }); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;roadLayer.setVisibleLayers([$('#ulLayerVisibility input[type="checkbox"]:checked').map(function () {&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; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt; var checkid = $(this).attr('id').split(":");&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; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;return checkid[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;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;}).get()]);&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; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;map = new Map("map", {&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; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;extent: customExtentAndSR&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; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&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;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;map.addLayers([roadLayer]);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 23:26:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739363#M68439</guid>
      <dc:creator>JohnPreston</dc:creator>
      <dc:date>2016-01-26T23:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739364#M68440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Not likely, The only way I can think that this would work is if you add the map object with not layers and then once the layer list is done getting the layer visibility from the database then have a function that will add the map layers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am really unsure of how you are attempting to use setVisibleLayers function here...&lt;/P&gt;&lt;P&gt;roadLayer.setVisibleLayers([$('#ulLayerVisibility input[type="checkbox"]:checked').map(function ()&lt;/P&gt;&lt;P&gt;setVisibleLayers function takes an array of layer ids.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 03:31:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739364#M68440</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-01-28T03:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739365#M68441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;I suggest a separate function to define an array of visibleLayers and then use that array as the input to setVisibleLayers.&amp;nbsp; What you have now makes no sense to me either.&amp;nbsp; Also, It seems like you want to start out with visibility:false and then not turn it back to true until you have your visibleLayers defined.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 22:10:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739365#M68441</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2016-01-29T22:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739366#M68442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you...&lt;/P&gt;&lt;P&gt;The ([$('#ulLayerVisibility input[type="checkbox"]:checked').map(function ()...returns an array of ids. It is a get function that return checked items from list. I use the same function to update visibility when user checks or unchecks an item in a list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are correct I need to get the layer list when it is done loading. That is my question...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Feb 2016 22:36:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739366#M68442</guid>
      <dc:creator>JohnPreston</dc:creator>
      <dc:date>2016-02-04T22:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739367#M68443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; With out seeing how you are getting the data from SQL Server (I can only assume you are using an esriRequest to a web service) it is hard to give a more define suggestion than I already have (i.e. get your layer vis request and then in the response function create the map object in code and add it the page). You do not have to have a map declared in html initially, you can add a map object programmatically.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2016 13:54:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739367#M68443</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-02-05T13:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739368#M68444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert, &lt;/P&gt;&lt;P&gt;I went a slightly different way than what I did initially...I make a specific call to SQL for visible layers, instead of using dynamically built list. Then I set visible layers with results from SQL call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; defaultVisible = [40, 51, 69, 65, 63, 64];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;'$.ajax({ &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type: "POST"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: myWebService&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contentType: "application/json; charset=utf-8"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataType: &lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;"json"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; async: false&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; success: function&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; (data) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; obj = jQuery.parseJSON(data.d);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; roadlayer.setVisibleLayer([obj]); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error: function&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; (data) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Unable to load Map Profile: '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; + data.status + &lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; + data.statusText);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; roadlayer.setVisibleLayer([defaultVisible]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;}); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2016 16:54:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739368#M68444</guid>
      <dc:creator>JohnPreston</dc:creator>
      <dc:date>2016-02-05T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: setVisibleLayers to a function</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739369#M68445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Glad you got it working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2016 16:56:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setvisiblelayers-to-a-function/m-p/739369#M68445</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-02-05T16:56:44Z</dc:date>
    </item>
  </channel>
</rss>

