<?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: Change layer visibility onLoad in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175755#M16342</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, the basemap_dynamic service doesn't have any layers turned on by default so you wouldn't see anything on the rest testing viewer. You can use the following viewer to view them if you like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://dev.geostor.arkansas.gov/g6/Viewer.html"&gt;http://dev.geostor.arkansas.gov/g6/Viewer.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Aug 2010 16:01:51 GMT</pubDate>
    <dc:creator>GlenRhea</dc:creator>
    <dc:date>2010-08-30T16:01:51Z</dc:date>
    <item>
      <title>Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175750#M16337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to change the visible layer displayed after the onLoad event for an ArcGISDynamicMapServiceLayer and it isn't working. I have a menu that works after the map is loaded but the layer that is visible initially is the one defined in the service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is too much code to post so here is a link to the app:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://goo.gl/vHmK"&gt;http://goo.gl/vHmK&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Aug 2010 14:37:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175750#M16337</guid>
      <dc:creator>GlenRhea</dc:creator>
      <dc:date>2010-08-26T14:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175751#M16338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wow, you used to be able to get help on ESRI's forums, apparently that isn't the case anymore. Too bad, they were a great resource.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 15:45:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175751#M16338</guid>
      <dc:creator>GlenRhea</dc:creator>
      <dc:date>2010-08-27T15:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175752#M16339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;THe link did not work for me&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Aug 2010 16:57:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175752#M16339</guid>
      <dc:creator>HaroldBostic</dc:creator>
      <dc:date>2010-08-27T16:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175753#M16340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Link works for me...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I took a quick look. Where do you add your dynamic layer to the map? I see where you create it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;//load basemap dynamic last so it's always on top
dn_layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://" + mapserv + ".geostor.arkansas.gov/ArcGIS/rest/services/BASEMAP_DYNAMIC/MapServer",{id:"dyn_layer"});
dyn_layer.setOpacity(".5")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;but I don't see where you add it to your map. Also, I can't get your dynamic layer to display from the services directory but I might be using the wrong URL:&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://www.geostor.arkansas.gov/ArcGIS/rest/services/Basemap_Dynamic/MapServer?f=jsapi" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.geostor.arkansas.gov/ArcGIS/rest/services/Basemap_Dynamic/MapServer?f=jsapi&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally, and this is just out of curiosity, what is the advantage to using your initLayer function rather than just creating and adding layers to your map?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:03:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175753#M16340</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2021-12-11T09:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175754#M16341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was having problems with my AGS services over the weekend, everything should be working again now. I add the "app" layers here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
 if (getUrlParam("app")) {
&amp;nbsp; //ex, layer = APP_SALINE
&amp;nbsp; var layer = getUrlParam("app");
&amp;nbsp; user_layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://" + mapserv + ".geostor.arkansas.gov/ArcGIS/rest/services/APPS/" + layer + "/MapServer",{id:"user_layer"});
&amp;nbsp; user_layer.setOpacity(".7")

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The initLayer function is just a generic function I use in all my JS apps to keep things consistent across apps. It also encompasses all the different layer types in one function as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I didn't get any email notifications from replies to this forum post because I didn't set that option. I should get an email as soon as someone replies this time, sorry for the delay.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your replies.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Glen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:03:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175754#M16341</guid>
      <dc:creator>GlenRhea</dc:creator>
      <dc:date>2021-12-11T09:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175755#M16342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, the basemap_dynamic service doesn't have any layers turned on by default so you wouldn't see anything on the rest testing viewer. You can use the following viewer to view them if you like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://dev.geostor.arkansas.gov/g6/Viewer.html"&gt;http://dev.geostor.arkansas.gov/g6/Viewer.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 16:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175755#M16342</guid>
      <dc:creator>GlenRhea</dc:creator>
      <dc:date>2010-08-30T16:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175756#M16343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Glen:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What's happening in your code is this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your init you are doing this:&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (getUrlParam("app")) {
243 //ex, layer = APP_SALINE
244 var layer = getUrlParam("app");
245 user_layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://" + mapserv + ".geostor.arkansas.gov/ArcGIS/rest/services/APPS/" + layer + "/MapServer",{id:"user_layer"});
246 user_layer.setOpacity(".7")
247 //we dont want identify for the districts app
248 if (!(layer.toLowerCase() == "app_districts")) {
249 dojo.connect(map, "onLayerAdd", mapLoaded);
250 } else if (layer.toLowerCase() == "app_districts" &amp;amp;&amp;amp; getUrlParam("title")) {
251 console.log("districts &amp;amp; title");
252 var title = getUrlParam("title");
253 if (title.toLowerCase() == "rep") {
254 console.log("districts &amp;amp; title &amp;amp; rep");
255 // should be app_districts &amp;amp; hor viewer, set hor layer visible
256 dojo.connect(user_layer, "onLoad", function(evt){console.log("user_layer loaded");changeHorMap([3])});
257 //dojo.connect(user_layer, "onLoad", function(evt){console.log("user_layer loaded");user_layer.setVisibleLayers([3])});
258 //dojo.connect(user_layer, "onLoad", user_layer.setVisibleLayers([3]));
259 }
260 }
261 }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the above code, specifically &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dojo.connect(user_layer, "onLoad", function(evt){console.log("user_layer loaded");changeHorMap([3])}); &lt;/PRE&gt;&lt;SPAN&gt; changes your visibile layer(s) to 3 which is the preferred layer (I assume)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;subsequently, later in your init you do this &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (dyn_layer.loaded) {
271 buildLayerList(dyn_layer,"layer_list");
272 buildLayerList(user_layer,"user_layer_list");
273 } else {
274 dojo.connect(dyn_layer, "onLoad", function(evt){ buildLayerList(dyn_layer,"layer_list", "Basemap Dynamic")});
275 if (getUrlParam("app")) {
276 dojo.connect(user_layer, "onLoad", function(evt){ buildLayerList(user_layer,"user_layer_list",getUrlParam("app"))});
277 }
278 } &lt;/PRE&gt;&lt;SPAN&gt; when I run the code I always hit this condition &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (getUrlParam("app")) {
276 dojo.connect(user_layer, "onLoad", function(evt){ buildLayerList(user_layer,"user_layer_list",getUrlParam("app"))});
277 } &lt;/PRE&gt;&lt;SPAN&gt; in your buildlayerlist function you are looking for the visible layers and setting your check boxes according to that, you are also setting the visible layers back to the default values EFECTIVELY OVERRIDING your previous code which changed the visible layer to 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So maybe in buildlayer list you want to check the "app" param and set your visible layer/checked layer according to what's currently visible in the mapservice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know the workflow for your site: but since the check boxes no longer appear in this layout, maybe when you check for "app" param, you don't have to worry about setting the check boxes and default layers at all.&amp;nbsp; Just some suggestions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if this helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. the short url did not work when I tried it in IE, hence my first comment of not being redirected (IE6 and IE8)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:03:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175756#M16343</guid>
      <dc:creator>HaroldBostic</dc:creator>
      <dc:date>2021-12-11T09:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175757#M16344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply Harold and I see what you're talking about now. It makes sense that I don't need to build the layer list when the map is embedded. I have changed the code and it is working now, I should have seen that but I wrote the buildLayerList function awhile back and I didn't even think to look at it &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll update the code on the dev site so yall can check it out.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 19:16:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175757#M16344</guid>
      <dc:creator>GlenRhea</dc:creator>
      <dc:date>2010-08-30T19:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Change layer visibility onLoad</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175758#M16345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Also, it's odd that the google url shortener didn't work in IE, here is the full path:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://dev.geostor.arkansas.gov/g6/viewer.html?embed=true&amp;amp;h=750&amp;amp;w=750&amp;amp;app=app_districts&amp;amp;title=rep"&gt;http://dev.geostor.arkansas.gov/g6/viewer.html?embed=true&amp;amp;h=750&amp;amp;w=750&amp;amp;app=app_districts&amp;amp;title=rep&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 19:18:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-layer-visibility-onload/m-p/175758#M16345</guid>
      <dc:creator>GlenRhea</dc:creator>
      <dc:date>2010-08-30T19:18:22Z</dc:date>
    </item>
  </channel>
</rss>

