[OpenLayers-Dev] events sequence question

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Fri Jan 19 10:29:17 EST 2007


Hi list,

during my recent spinner image development I noticed a problem when I would
be at the deepest zoom level in the map, and I would use the mousewheel to
zoom in further. OpenLayers is smart in this case and does not retrieve a
new image.

So I changed the moveTo function of Untiled.js, to fire off a layerloaded
event in the else loop, i.e.:

if ( zoomChanged || firstRendering || (!dragging && outOfBounds) )   {
  ..
}
else
{
  this.fireLayerLoaded();
}

This did not work however, because the layerloaded event comes in *before*
the moveend event. Map.js fires a moveend event, even if nothing happened:

            if (moveLayer) {
                layer.moveTo(bounds, zoomChanged, dragging);
            }
        }                
    }
    
    this.events.triggerEvent("move");

    if (zoomChanged) { this.events.triggerEvent("zoomend"); }
}

// even if nothing was done, we want to notify of this
if (!dragging) { this.events.triggerEvent("moveend"); } 

Normally when loading images this goes correctly, since the layerloaded
event will only come in after the image has loaded, so after the moveend
event has been triggered. But if no image needs to be loaded, it screws up
the event sequence.

I patched this with a setTimeout, but am e-mailing the dev list if there is
a better way around this:

else { window.setTimeout(this.fireLayerLoaded, 100); }

Erik, btw, I haven't had the chance to move the event to the Layer object,
and to change the name to unload, but will do this next week.

Thanks in advance.

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl








More information about the Dev mailing list