adevine

Introducing Delay in Showing featureLayers

Discussion created by adevine on Feb 7, 2013
Latest reply on Feb 8, 2013 by adevine
Afternoon,

I am finalizing a project for work and had been developing with the 2.8 JSAPI. I switched over to 3.2 this afternoon with my development site and noticed something strange: the performance of the web app had improved so much that featureLayers were beginning to draw before an extent change could be executed! The resulting effect is less smooth than the intrinsic delay I had before at 2.8. My question is: What would be the most effective way to introduce a delay in the execution of my code?

My app leverages the basemapGallery widget to allow the user to choose between 24 data displays that are structured hierarchically (Main category, subcategory1 and subcategory2). This is controlled by a switch statement with 25 cases. each of these cases is structured like so:
              case "water":
                    sustainBase.setVisibleLayers([0, 2, 7, 9, 10]);
                    hideSustainLayers();
                    var waterExtent = new esri.geometry.Extent({ "xmin": 2532200, "ymin": 1416000, "xmax": 2577300, "ymax": 1442750, "spatialReference": { "wkid": 102667} });
                    map.setExtent(waterExtent.expand(1.5));
                    basemaps.length = 0;
                    basemaps.push(main_Basemap);
                    basemaps.push(water_cisterns);
                    basemaps.push(water_grroofs);
                    basemaps.push(water_porpave);
                    basemaps.push(water_raingar);
                    basemaps.push(water_strrest);
                    recreateBasemapGallery();                   
                    featureLayers[0].show();
                    featureLayers[2].show();
                    featureLayers[9].show();
                    featureLayers[7].show();
                    featureLayers[10].show();
                    break;


As you can see the code sets visible feature layers, hides the feature layers from the previous view, defines and sets the extent, reconfigures the basemapGallery and recreates it and, finally, shows the feature layers desired for the new view.

Any ideas pop to mind?

Thanks, in advance,

Alex

Outcomes