OpenLayers OpenLayers

Ticket #1220 (closed bug: fixed)

Opened 1 year ago

Last modified 10 months ago

conflict between addlayer and loadstart event

Reported by: bartvde Assigned to:
Priority: minor Milestone: 2.6 Release
Component: Map Version: 2.5
Keywords: Cc:
State: Complete

Description

Currently the addlayer event is triggered in Map.js at the end of the function, after redraw has already been called on the layer.

This means that code listening for addlayer events (like the LoadingPanel Control) can never in time register for loadstart events on that layer. It will always be too late and will only get in the loadend event.

Is is acceptable to fire the addlayer event a bit earlier in the function, before the if (layer.isBaseLayer) line? Any other solution?

Attachments

preaddlayer.patch (1.0 kB) - added by crschmidt on 02/09/08 09:37:46.
pre.patch (1.5 kB) - added by tschaub on 02/15/08 18:03:25.
add support for preaddlayer event

Change History

12/19/07 07:49:06 changed by crschmidt

I think that at the time, We wanted people to be able to be sure the layer was fully added to the map. For example, if we drop this, I don't think ther'es a way (other than code duplication) to tell if the layer is going to be the next base layer... right?

Maybe it's possible to do this without having any negative affects by reworking the logic here, but I'd like to make sure we don't lose anything that would be useful -- even at the expense of, for example, adding an extra event.

01/08/08 20:59:30 changed by euzuro

like "beforelayeradd" "afterlayeradd" ?

01/28/08 05:21:07 changed by bartvde

  • milestone set to 2.6 Release.

Chris, Erik, is this something we can tackle before the 2.6 release? This is essential for something like LoadingPanel to work properly.

02/05/08 01:51:32 changed by euzuro

if it's essential for loadingpanel, then yes, we will have to tackle it for 2.6.

I'll try to look at it later this week.

02/09/08 09:37:46 changed by crschmidt

  • attachment preaddlayer.patch added.

02/09/08 09:38:18 changed by crschmidt

  • state set to Review.

Add preaddlayer event, defined to be called before the layer is added to the map.

02/09/08 16:24:09 changed by bartvde

Chris, you need to add the new event type to the EVENT_TYPES array as well or not?

    EVENT_TYPES: [ 
        "addlayer", "preaddlayer", "removelayer", "changelayer", "movestart", "move", 

02/15/08 17:39:23 changed by tschaub

  • state changed from Review to Needs More Work.

Yeah, we need the event in the EVENT_TYPES array and it would be good to document it. I also like Erik's suggestion of "beforelayeradd" - but since we already have "addlayer" I guess prepending that is more consistent.

FWIW, I think the browser event naming scheme works pretty well: {object}{action}. We can augment that to {prefix}{object}{action}. I know this map stuff all goes against that, but for future stuff I think it makes sense to follow browser event naming convention.

02/15/08 18:03:25 changed by tschaub

  • attachment pre.patch added.

add support for preaddlayer event

02/15/08 18:08:31 changed by tschaub

  • state changed from Needs More Work to Commit.

02/20/08 18:39:46 changed by tschaub

  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6329]) Adding a preaddlayer event for maps. This is triggered before a layer is added. r=me (closes #1220)