how to implement a "Loading" message after a layer is checked in the TOC

871
9
05-10-2012 06:27 AM
AshleyOwens
New Contributor II
I know how to implement a "Loading" message within a widget to inform the user the widget is processing. 
Is there a way to have a similar "Loading" message after a layer is checked in the TOC and before the layer loads?
Tags (2)
0 Kudos
9 Replies
MLowry
by
Occasional Contributor II
I know how to implement a "Loading" message within a widget to inform the user the widget is processing. 
Is there a way to have a similar "Loading" message after a layer is checked in the TOC and before the layer loads?


There's a loading widget in the gallery that shows the progress bar when the basemap is being rendered and when layers are being rendered.
0 Kudos
EricVenden
Occasional Contributor II
There's a loading widget in the gallery that shows the progress bar when the basemap is being rendered and when layers are being rendered.


The progress bar widget (http://www.arcgis.com/home/item.html?id=acc90fd144904f2eb3bca757967b1f83) is available that does what you are looking for....however, I have found one issue with the widget.  It appears that if cached, operational layers are turned on that have a zoom threshold set AND the map is not zoomed in enough to turn these layers on, then the progress bar will displayed "forever".  I haven't really looked into fixing this...yet.

Eric
0 Kudos
AshleyOwens
New Contributor II
Thanks!  That answers my question.  Any idea when it will be fixed?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ashley,

   I would recommend this one instead:

http://forums.arcgis.com/threads/9585-MapProgressBar-widget-for-SFV-2.0

But it still need changes to make it work with tiled map services and custom LODs as well.

<widget horizontalcenter="0" verticalcenter="0" url="widgets/MapProgressBar/MapProgressBarWidget.swf"/>


Here is the widget will all the necessary changes:
0 Kudos
JosephGrubbs
New Contributor III
Has anyone configured this progress bar widget to show on the initial load of the operational layer(s)?  I'm working from the widget's source code, and everything works fine for extent changes, etc.  However, I'd like to have the progress bar show on the initial map load in case it takes a few moments for my operational layers to load.  Any suggestions?

Thank you,

Joe
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Joe,

   Because of timing issues I don't believe that you will be able to achieve this as the widgets life cycle beginning is after the maps in the whole viewers scheme. Of course if you were to put all the widgets logic in the MapManager.mxml than you could do it.
0 Kudos
JosephGrubbs
New Contributor III
Robert - Understood.  Right, that makes sense.  Thank you, again!

Joe
0 Kudos
JamesFaron
Occasional Contributor
I am using Robert's revision of Chen's MapProgressBar widget. I have a tiled mapservice layer (parcels) that has a max scale of 1:8,000. When I zoom in and that layer activates, the progress bar disappears as expected, but when I zoom out beyond the max scale of the parcels layer, the progress bar hangs. I think that it has to do with the following code:
protected function layerUpdateEndHandler(event:LayerEvent):void
   {
    var lyr:Layer = event.layer;
    //once a layer finished its update,remove the layer from layer collection
    if (layerColl.contains(lyr)){
     layerColl.removeItemAt(layerColl.getItemIndex(lyr));
    }
    //all layers finished their loading and rendering,hide the progress
    pb.visible = !layerColl.length == 0;
    trace(layerColl.length);
   }
The protected function is supposed to iterate with each layer in the layerColl, but for some reason (since the layer in question is no longer in the refreshed map?), the layerUpdateEndHandler does not run to remove that layer, thus the condition pb.visible = !layerColl.length ==0 is still in effect, since layerColl still contains the parcels layer. In other words, if a layer is removed as the result of an extent change, it does not seem to activate the mapLayerRemoveHandler, since it is not registered by the MapEvent.LAYER_REMOVE event???

I hope my explanation is clear. Any help will be greatly appreciated.

Thanks,
Jim Faron
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Jim,

   I really thought that I had that handled by this function:

            protected function layerUpdateStartHandler(event:LayerEvent):void
            {
                //once a layer starts to update,show the progressbar
                pb.visible = true;
                var lyr:Layer = event.layer;
                //If a ArcGISTiledMapServiceLayer has Display Levels defined and the map has custom
                //LODs defined than it takes this extra work to determine if the layer is actually
                //drawing at this LOD and if not then just return and do not add this layer to the
                //layerColl
                var Lod:LOD = map.lods[map.level];
                if (lyr is ArcGISTiledMapServiceLayer){
                    var tLyr:ArcGISTiledMapServiceLayer = lyr as ArcGISTiledMapServiceLayer;
                    if(tLyr.displayLevels){
                        var pLodFound:Boolean;
                        for each(var tLod:LOD in layerTileInfoCache[tLyr]){
                            if (tLod == Lod) pLodFound = true;
                        }
                        if(!pLodFound) return;
                    }
                }
                
                if(!lyr.isInScaleRange) return; //Which means that the layer never gets added to the collection
                
                //add the layer to layer collection
                if (!layerColl.contains(lyr)){
                    layerColl.addItem(lyr);
                }
            }


I will have look into it more when I get a chance.
0 Kudos