[OpenLayers-Users] Map load event?

Steve Nelson snelson at webapper.com
Sat Apr 21 01:34:16 EDT 2012


I know there is a loadstart and loadend event for each layer. I'm certain
there is a more elegant solution that this, but you could create a dynamic
list yourself. Maybe something like this?


//add eventListeners to your layers like this:
var OSMLayer = new OpenLayers.Layer.OSM("OpenStreetMap","
http://tile.openstreetmap.org/${z}/${x}/${y}.png",{eventListeners:
{"loadstart": layerLoadStart,"loadend": layerLoadEnd}})


//create an object with your layers
var layers=new Object
function layerLoadStart(e){

//using the id of the layer, mark it as 'started'
layers[e.object.id]="started"
}
function layerLoadEnd(e){

//when it finishes, mark it as 'loaded'
layers[e.object.id]="loaded"

}

On Wed, Apr 18, 2012 at 3:23 AM, Tobias Reinicke <ramotswa at gmail.com> wrote:

> Hello All,
>
> I might have missed where this has been written, but is there not a
> "loadend" event for the entire map (rather than on a layer basis?). If
> not, what is the best way to check that all layers on a map have
> finished loading? I know there was some work done on the Loading Panel
> add-in, but as far as I can tell this iterates through all layers and
> registers loadend events on them.
>
> Any help would be be much appreciated.
>
> Regards,
>
> Toby
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120421/59c7753f/attachment.html


More information about the Users mailing list