AnsweredAssumed Answered

Feature layers added to map with visible property false cannot be toggled on/off.

Question asked by mukta.puri on Jul 13, 2016
Latest reply on Jul 14, 2016 by ubatsukh-esristaff


I have found that if we add a Feature Layer to a map with visible property set to false like so, we cannot toggle the layer back on by just setting the visible property back to true:

       // If visible is false when adding the feature layer, cannot toggle the layer back on by clicking the button

    var featureLayer = new FeatureLayer({

      url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0",

      visible: false

    });

    map.add(featureLayer);

However, if we set the visible property to true while adding the layer, the layer can be toggled on/off by setting visible property true/false.

 

Here is a JS Fiddle showing visible property false when adding the layer (Here is the bug):  JSFiddle

Here is a JS Fiddle showing visible property true when adding the layer: JSFiddle

 

Is there a workaround around this? Is the fix for this bug in the Esri backlog?

 

Note: some other layers (eg: vector tile layers) do seem to work ok even though the visible property is false when adding the layer. I have seen this bug only in the feature layer so far.

Outcomes