Tuesday 24 May 2016

openlayers 2 - Is there a map-level event to signal the start/end of drawing?


In OpenLayers, is there an event which fires when the map starts drawing any layer, and another for when the map has finished drawing all layers?



I wish to display a "waiting" animation while any layer is still drawing.


The help file for LoadingPanel mentions something which sounds promising, but the sample doesn't work and it mentions tiles (I'd like it to work on vector layers too).


I'm looking for the equivalent of dojo.connect(map,"onUpdateEnd"... in the ArcGIS JS API:



Fires after layers that are updating their content have completed. This event is often used in combination with onUpdateStart to display a "Map is busy" or "Loading? " message as visual feedback to the end-user.



(As a workaround, I could count the layers in the map, and monitor the status of each layer using layer.events.register("loadend"... until they have all finished. Are there other options?)


Thanks



Answer



A loading panel is available as an add-in and was first mentioned here. You can either use that or hack it to suit your needs; anyway imho it provides good enough functionality.



The linked example does not work so I took the liberty of assembling a working jsfiddle:


http://jsfiddle.net/bxpjT/1/


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...