[OpenLayers-Users] RegisterEvents - registering prior to layer loaded

Andrew de Klerk andrew.deklerk at gmail.com
Mon Sep 15 05:56:39 EDT 2008


Hi all

I will try and explain this as best as I can. I have a register events
function to display a progress indicator. I call this function from my
mapinit function like this:
------------------------------------
<....code before....>
registerEvents(labels);   
registerEvents(mainmap); 
	
mlayer = new OpenLayers.Layer.Vector( "Measure");

map.addLayers([mainmap,labels]);
map.addLayer(mlayer);
	    
<...code after...>
------------------------------------
Here is my register events function:
------------------------------------
function registerEvents(layer) {
        layer.logEvent = function(event) {
        eventsLog.innerHTML =ajaxloadimg2 + this.name + ": " + event;    
        eventsLog.style.display = "block";
    }
            
    layer.events.register("loadstart", layer, function() {
        this.logEvent("Loading..");
    });
     
    layer.events.register("tileloaded", layer, function() {
        this.logEvent("Loading... " + this.numLoadingTiles + " left.");
    });
            
    layer.events.register("loadend", layer, function() {
        alert("test"); 
        this.logEvent("Loaded");
        eventsLog.style.display = "none" 
    });
 }
----------------------------------

My register events function gets called, and works well on initial zooms.
However, as one zooms in further (after a couple of zoom clicks) the
"loadend" event gets called immediately, prior to the map getting redrawn. I
have tested this with the alert shown in the function above. What this
results in is that my progress indicator div gets hidden immediately prior
to the map being reloaded. Any ideas why this is so?, and I hope this makes
sense.

I am using OL 2.6

Thanks
Andrew





More information about the Users mailing list