AnsweredAssumed Answered

Select ArcGISdynamiclayer by unique IDs to modify opacity

Question asked by AlexSabrina on Nov 18, 2014
Latest reply on Nov 19, 2014 by AlexSabrina

Hi all,

I am trying to create an opacity control button that would allow users to modify opacity for each layer within an ArcGIS dynamic layer (for instance layer0, layer1, layer3). I have a script that runs fine for the whole  ArcGISDynamicLayer:

<!DOCTYPE html>  
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
  <!--The viewport meta tag is used to improve the presentation and behavior of the samples     
      on iOS devices-->  
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">  
  <title>Explicitly Create Map Service Layer List</title>  
  <link rel="stylesheet" href="" />  
  <link rel="stylesheet" href="">  
  <link rel="stylesheet" href="">  
  <link rel="stylesheet" href="">  
  <link rel="stylesheet" href="">  
  <script src=""></script>  
  <script src=""></script>  
  <script src=""></script>  
    var map;  
      function (Map, ArcGISDynamicMapServiceLayer, ImageParameters, dom, on, query) {  
        var layer, visibleLayerIds = [];  
        map = new Map("map");  
        //Use the ImageParameters to set the visibleLayerIds layers in the map service during ArcGISDynamicMapServiceLayer construction.    
        var imageParameters = new ImageParameters();  
        imageParameters.layerIds = [2];  
        imageParameters.layerOption = ImageParameters.LAYER_OPTION_SHOW;
        layer = new ArcGISDynamicMapServiceLayer("", {  
          "imageParameters": imageParameters
        on(dom.byId("opacity"), "click", updateOpacity); 

        function updateOpacity() {  
          var cOp = layer.opacity;  
          if (cOp < 0.9999999999999999) {  
            layer.setOpacity(cOp + 0.1);  
          } else {  
  This sample loads an ArcGISDynamicMapServiceLayer and presents a button to adjust the map services opacity.  
  <br />  
  <br />Layer List :  
  <button type="button" class="btn btn-default btn-xs" title="Adjust opacity" id="opacity"><span class="glyphicon glyphicon-adjust"></span>  
  <button type="button" class="btn btn-default btn-xs" title="Adjust opacity" id="opacity2"><span class="glyphicon glyphicon-adjust"></span>  
  <br />  
  <br />  
  <div id="map" class="claro" style="width:600px; height:400px; border:1px solid #000;"></div>  



Any ideas are welcome,

Thank you,