AnsweredAssumed Answered

ImageService - Not being able to turn off

Question asked by Nipa on Apr 19, 2012
Latest reply on Apr 19, 2012 by khutchins-esristaff
Hello,

I'm trying to add the imageservice when the user clicked on the checkbox and when the user unchecks the checkbox I would like to remove that layer.  Below is my code but it's not removing layer.

Can someone please take a look at it and let me know what's wrong.

function updateImageServiceVisibility() {
        var imageServiceName = "";
        
        if (selState == "Select") {
          alert("Please Select State to display the imageService");
          return;
        } else if (selState == "ESI_Alabama_Data") {
          imageServiceName = "ESI_Alabama_Maps"
        } else if (selState == "ESI_DE_NJ_PA_Data") {
          imageServiceName = "ESI_DE_NJ_PA_Maps"
        }
       
        var params = new esri.layers.ImageServiceParameters();
        params.noData = 0;
        params.format = "jpgpng";
        var imageServiceLayer = new esri.layers.ArcGISImageServiceLayer(serverName + "ArcGIS/rest/services/ESI/" + imageServiceName + "/ImageServer", {
          imageServiceParameters: params
        });
       
        if (dojo.byId("imageServicechkBox").checked) {
          map.addLayer(imageServiceLayer); 
         } else {
          imageServiceLayer.visible = false;
          map.removeLayer(imageServiceLayer);
        } 
      }

When I degug it does hit the else but removelayer is not happening.

Thanks for your help.

Nipa

Outcomes