Select to view content in your preferred language

Realy need help how to display certain layer when there are many layers in the serice

538
2
07-08-2010 04:02 AM
HallbjornViktorsson
Emerging Contributor
Hello,
I'm just trying to display a map, my service has 51 layers of different maps on it and I want to display just a certain layer, i was wondering how that is done. I know how to display the map with all the layers at once but I can't active it with just certain layer on. if any one know how I can do this and can tell me that would be Awesome.  if you need more info or I wasent clear please let me know so I can try ex-plane better.
0 Kudos
2 Replies
derekswingley1
Deactivated User
Assuming you're working with a dynamic map service, you want setVisibleLayers():  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/arcgisdynamicmapservicelayer.htm#setVi...
0 Kudos
HallbjornViktorsson
Emerging Contributor
so I have come up with this code but I get a error that sas map.setVisibleLayers is not a function am I useing setVisibleLayers in a wrong way or what other way can I do this some one knows?

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>Create Map</title>
    
 <link rel="stylesheet" type="text/css" href="lib/dijit/themes/tundra/tundra.css">
 <link rel="stylesheet" type="text/css" href="lib/dojox/grid/resources/Grid.css">
 <link rel="stylesheet" type="text/css" href="lib/dojox/grid/resources/tundraGrid.css">
 
 <script type="text/javascript" src="../src/dojo.js.uncompressed.js" ></script>
    <script type="text/javascript" src="serverapi.js"></script>
 <script type="text/javascript">
  
  
      dojo.require("esri.map");
   dojo.require("esri.tasks.query");
   
   
   var map;

      function init() {
        map = new esri.Map("map"); 

        
        var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("your server");
  map.addLayer(dynamicMapServiceLayer).hide();  
  
      }
   
   function SetLayer(){
    var test1 = [];
  test1[0] = 44;
  
  map.setVisibleLayers([44]).show();
 
   }

      dojo.addOnLoad(init);
    </script>
  </head>
  <body class="tundra">
    <div id="map"></div>
 <input type="button"  value="Set Layer" onclick="return SetLayer();" />
  </body>
</html>
0 Kudos