Select to view content in your preferred language

Loading... message - what event to connect to?

514
2
04-07-2010 05:15 AM
JamesGonsoski
Occasional Contributor
Comrades,

I'm creating an application based on the JavaScript API Viewer sample. I have a simple GIF that displays a Loading... message that I wish to hide after all the map layers display on-screen.

I've tried to tie hiding the message to various events and they all fire too soon for my dynamic ArcSDE-based service which can take as long as 5 seconds on average to appear.

I've tested connecting hiding the message to 1) map onLoad 2) map onLayerAdd 3) layer onLoad and 4) layer onUpdate and all these events seem to fire too soon.

I'm specifically looking for an event that screams 'I am all done and the map is completely displayed'. But what event is that?

Any help is appreciated.

Jim G.
GIS Specialist, Mn Dept of Agriculture
0 Kudos
2 Replies
JamesGonsoski
Occasional Contributor
For what it's worth, after a another day's worth of experimenting, I solved my problem by:
1. After the map successfully loads, I use a dojo.connect to tie displaying the Loading... message to the map 'onExtentChange' event. That particular event avoids needless message displays while layers are merely being turned on and off.
2. After the last dynamic layer is loaded, I use a dojo.connect to tie hiding the Loading... message to the last layer's 'onUpdate' event. Since this layer is usually the slowest to load, it's normally the last event to fire.

The tricky bit is figuring out which of the layers being loaded through a configuration file is the 'last dynamic layer', but that's another story.
0 Kudos
JamesGonsoski
Occasional Contributor
Oh...

Did I forget to mention that the last layer needs to be visible? As Kelly has noted in other forum posts, the layer onUpdate event only fires if the layer is visible.
0 Kudos