AnsweredAssumed Answered

underbelly of .setVisibility() method for Feature Layer?

Question asked by sarahclark on Aug 11, 2014
Latest reply on Aug 15, 2014 by sarahclark

Hi - I am struggling with what I believed was asynchronous behavior from the setVisibility method on a feature layer. I have a huge feature layer that, to avoid issues, has visibility set to false on load. After clearing the layer's graphics and adding a new, smaller set of graphics, I was setting visibility to 'true'. However all of the thousands of feature graphics kept showing up anyways. I tried using Dojo deferreds and rearranging when I changed visibility to no avail. The only thing that worked was changing the visibility, letting the entire map update, then clearing the graphics.


console.log('set visibility');
var wait = on(map, 'update-end', function() {
   // Function to clear graphics 


However, this still flashes all of the layer's graphics before clearing them. Suspending drawing on the feature layer did not stop the flashing problem, and if I change the graphics first then wait and change visibility, it overrides the changes I made and loads the original layer's thousands of graphics when it is made visible.


So I am wondering what setVisibility() is doing to override what I input as graphics. I can see the altered layer with 28 features in the console log if I do not change visibility and the visibility is set to false, but if I change the graphics to the 28 features (results from a query) then set visibility to true after all updates are done, 1500 graphics are returned from the original feature layer even though I cleared them all...