[OpenLayers-Users] wms untiled 'busy loading' message or image

Erik Uzureau erik.uzureau at metacarta.com
Tue Jul 10 10:32:51 EDT 2007


btw:
http://dev.openlayers.org/sandbox/euzuro/untiled3/examples/layerLoadMonitoring.html

On 7/10/07, Erik Uzureau <erik.uzureau at metacarta.com> wrote:
> Dear Benoit et tous,
>
> I'm actually working on getting reliable loadstart/loadend messages
> going in a sandbox that I've been working on for the past couple of
> weeks.
>
> I'm hoping to write tests today and have a patch ready and hopefully
> integrated by the end of the week.
>
> Once in (cross fingers), all layers derived of Grid.js will correctly
> fire "loadstart", "loadend" and "tileloaded" events. Similar to your
> implementation below, there will be a new property on the grid layer
> called numLoadingTiles, which can be used to implement a progress bar.
>
> Keep an eye out for it,
> Erik
>
>
>
>
> On 7/10/07, Benoit Myard <myardbenoit at gmail.com> wrote:
> > // Here is the code:
> >
> > OpenLayers.Control.LoadMonitor = OpenLayers.Class.create();
> > OpenLayers.Control.LoadMonitor.prototype =
> >   OpenLayers.Class.inherit( OpenLayers.Control, {
> >
> >     div: null,
> >     counter: 0,
> >
> >     activate: function() {
> >       var img = OpenLayers.Util.getImagesLocation() + "loading.gif";
> >       var size = new OpenLayers.Size(40, 40);
> >       var dim = OpenLayers.Element.getDimensions(this.map.viewPortDiv);
> >       var pos = new OpenLayers.Pixel((dim.width - size.w) / 2,
> >                                     (dim.height - size.h) / 2);
> >
> >       this.div = OpenLayers.Util.createDiv("LoadMonitor", pos, size, img);
> >       this.div.style.zIndex = 1000;
> >
> >       this.map.viewPortDiv.appendChild(this.div);
> >     },
> >
> >     deactivate: function() {
> >       if (this.div) {
> >         this.div.style.display = "none";
> >         this.div = null;
> >       }
> >     },
> >
> >     draw: function() {
> >       this.activate();
> >     },
> >
> >     monitor: function(layer) {
> >       layer.events.register('loadstart', this, this.start);
> >       layer.events.register('loadcancel', this, this.end);
> >       layer.events.register('loadend', this, this.end);
> >     },
> >
> >     start: function(layer) {
> >       this.counter++
> >       if (this.counter > 0 && this.div)
> >         this.div.style.display = "block";
> >     },
> >
> >     end: function(layer) {
> >       if (this.counter > 0)
> >           this.counter--;
> >       if (this.counter == 0 && this.div)
> >         this.div.style.display = "none";
> >     },
> >
> >     CLASS_NAME: "OpenLayers.Control.LoadMonitor"
> > });
> >
> > // And here is an example:
> >
> > var map = new OpenLayers.Map(...);
> >
> > var monitor = new ExpWeb.Control.LoadMonitor();
> > map.addControl(monitor);
> >
> > var layer = new OpenLayers.Layer.WMS(...);
> > monitor.monitor(layer);
> > map.addLayer(layer);
> >
> > It's not automated because I had to have the ability to choose which
> > layer to monitor. Also, for some reason, events are somewhat strange.
> > Add breakpoints in start() and end() if you use FireBug and note
> > events triggered. Any idea ?
> >
> > Cheers.
> >
> > --
> > Benoit Myard
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
>



More information about the Users mailing list