AnsweredAssumed Answered

ArcGISDynamicMapServiceLayer's setVisibleLayers not working for me

Question asked by myESRIUName on Dec 3, 2012
Latest reply on Dec 5, 2012 by myESRIUName
I think there is some basic principle to the ArcGISDynamicMapServiceLayer's setVisibleLayers functionality that I am not undersanding and I'm hoping someone can tell me what I'm missing.  Certainly, any of the forum posts I've found suggest that it works as I expect but I can't seem to affect the display of my map as I wish.

I have created the example below to illustrate what I am trying to do in my application with my own data. Here, I am using's Water_Network service and setting the visible layers for the service to "MidScale" (19) and "Water Mains - Block View" (23). However, when I load the page, the map is also showing "Water Network Structures - City View" (layer 20). The circle with the letter 'T' is from that layer; and, as far as I am concerned, should not be displayed in the map given the setVisibleLayers([19,23]) call I am making.

Can anyone tell me what I am missing here? Is there something else I'm supposed to do besides just pass an array identifying the visible layers I want shown?


<html>   <head>     <title>setVisibleLayers Question</title>     <link rel="stylesheet" type="text/css" href="">     <link rel="stylesheet" type="text/css" href="" />     <script type="text/javascript" src=""></script>  <script type="text/javascript"> dojo.require("");  function init() {     var extent = new esri.geometry.Extent(         {             "xmin":1016752.0585392233,"ymin":1857876.6670321897,"xmax":1051557.2503922875,"ymax":1876696.1114766342             ,"spatialReference":{                 "wkt": "PROJCS[\"NAD_1983_HARN_StatePlane_Illinois_East_FIPS_1201\",GEOGCS[\"GCS_North_American_1983_HARN\",DATUM[\"D_North_American_1983_HARN\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",984250.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-88.33333333333333],PARAMETER[\"Scale_Factor\",0.999975],PARAMETER[\"Latitude_Of_Origin\",36.66666666666666],UNIT[\"Foot_US\",0.3048006096012192]]"             }         }     );      var map = new esri.Map("map",{extent: extent});      var service = new esri.layers.ArcGISDynamicMapServiceLayer("");      // I've tried setting the visibleLayers before and after adding the ArcGISDynamicMapServiceLayer to the map     // Here, I also tried the optional "false" to refresh, even though I hadn't added it to the map yet      //service.setVisibleLayers([19,23]);      map.addLayer(service);      service.setVisibleLayers([19,23], false); } dojo.addOnLoad(init); </script>   </head>   <body>     <div id="map" class="claro" style="width:1130px; height:611px; border:1px solid #000;"></div>   </body> </html>