OpenLayers OpenLayers

Ticket #452 (closed feature: fixed)

Opened 2 years ago

Last modified 2 years ago

need an event to know when overlays finish loading

Reported by: openlayers Assigned to: euzuro
Priority: minor Milestone: 2.4 Release
Component: Layer Version:
Keywords: Cc:
State:

Description

This is especially needed for WMS.Untiled, not so much for tiled datasources. If you want to show a spinner/processing image, you need to know when to remove it.

I'll see if I can come up with something, though my OpenLayers knowledge is pretty limited right now.

Bart van den Eijnden

Attachments

layerloaded.patch (2.4 kB) - added by openlayers on 01/22/07 05:38:57.
patch to implement an onload event for WMS.Untiled
layer.patch (0.9 kB) - added by bartvde on 02/01/07 06:40:06.
patch for Layer.js
untiled.patch (1.3 kB) - added by bartvde on 02/01/07 06:40:23.
patch for Untiled.js
layer_loading.patch (2.5 kB) - added by euzuro on 02/04/07 11:02:09.
combination of bart's two patches with some very small stylistic changes

Change History

01/09/07 08:48:19 changed by openlayers

Note Trac only shows the first part of the patch, so you need to download it in its raw format.

01/17/07 13:37:51 changed by euzuro

  • owner set to euzuro.
  • status changed from new to assigned.

I like the idea behind this patch very much, but I think the right way to do this is not to tag the event to the Map but rather to give the OpenLayers.Layer class its own Events object, and make "onload" the name of the event.

If anyone wants to re-write this patch, then I think it will be a great addition to the code base. Who knows what other events we might want to add to Layer!?

If noone volunteers, I'll re-write it myself... just as soon as I have a spare minute... ;-)

01/22/07 04:55:52 changed by openlayers

Here is a new patch which implements Erik's suggestions. I've also added a better patch than window.settimeout to the problem I described on the dev list when images come from cache.

Erik, I tried logging in with my bartvde account, but I had no privileges on the ticket. Is something wrong with the permissions of my user account?

01/22/07 05:38:57 changed by openlayers

  • attachment layerloaded.patch added.

patch to implement an onload event for WMS.Untiled

01/23/07 02:39:37 changed by bartvde

Test comment.

01/25/07 07:19:44 changed by bartvde

After some discussion with Erik we decided its best to have a loadstart and loadend event on the Layer instead.

I've implemented this in two new patches: -layer.patch -untiled.patch

01/29/07 05:44:03 changed by bartvde

Erik, another question, do we not also need an error event when the image fails to load, so the counter can be decreased by one in that case. This is especially the case if the somebody has set the IMAGE_RELOAD_ATTEMPTS parameter.

Something like:

OpenLayers.Event.observe(this.tile.imgDiv, 'error', function() { this.events.triggerEvent("loaderror"); }.bindAsEventListener(this));

?

01/31/07 08:37:44 changed by bartvde

Another concern with this approach: if I use the mousewheel very fast, so requesting the second image before the first one comes in, there is also a problem since not enough loadend events will come in.

Here my OpenLayers internals knowledge is too limited to think of a solution, do you have any hints/pointers?

02/01/07 06:39:43 changed by bartvde

Okay, I fixed the last-mentioned issue in Untiled.js, and will attach new patches incorporating also this change. I added an event called loadcancel, which is issued when the src of the image is set before the previous one has finished loading.

02/01/07 06:40:06 changed by bartvde

  • attachment layer.patch added.

patch for Layer.js

02/01/07 06:40:23 changed by bartvde

  • attachment untiled.patch added.

patch for Untiled.js

(follow-up: ↓ 10 ) 02/04/07 10:59:04 changed by euzuro

Bart, these new patches look great! I've made a few small stylistic changes and am re-adding them smooshed together as one file ( svn diff > diff.js from trunk). Thanks a bunch for your work on this patch! This is a great addition to OpenLayers :-)

(in reply to: ↑ 9 ) 02/04/07 11:00:28 changed by euzuro

Replying to euzuro:

( svn diff > diff.js from trunk)

actually svn diff > layer_loading.patch

:-)

02/04/07 11:02:09 changed by euzuro

  • attachment layer_loading.patch added.

combination of bart's two patches with some very small stylistic changes

02/04/07 11:14:15 changed by euzuro

  • component changed from general to Layer.
  • milestone set to 2.4 Release.

committed with r2200

02/04/07 11:14:38 changed by euzuro

  • status changed from assigned to closed.
  • resolution set to fixed.