3

I already asked this question in Stack Overflow. I don't want to spam by asking again here but I think the question fits better in GIS SE. I am sorry for the replication. Feel free to delete one of the two questions.

Let's start!

I am working with OpenLayers 2. I am using the events "loadstart" and "loadend" from here.

When I use OpenLayers.Layers.WMS, i want to have some kind of callback when there is a loading error. For example, when I enter an incorrect SLD filter, I want to have some feedback about the layer not being loaded correctly. Unfortunately, "loadend" doesn't provide this kind of error detection.

I already found this question where someone else has the same problem.

Is there even an event that signals this kind of error?

Is there something like a "layerfail" or "layererror" event?

How could I implement this?

3

This is already documented here. There are two undocumented tileerror events for the layer

When a single tile is missing it trigger the event
“loadwarning” to indicate that something is wrong with this layer.
When all the tiles in a layer are missing it trigger the event
“loadfail”.

There is also some additional documentation in the code here

UPDATE ========

It seems that here has a different implementation with

beforedraw  Triggered before the tile is drawn.  Used to defer drawing to an animation queue.  To defer drawing, listeners need to return false, which will abort drawing.  The queue handler needs to call <draw>(true) to actually draw the tile.
loadstart   Triggered when tile loading starts.
loadend Triggered when tile loading ends.
loaderror   Triggered before the loadend event (i.e. when the tile is still hidden) if the tile could not be loaded.
reload  Triggered when an already loading tile is reloaded.
unload  Triggered before a tile is unloaded.
  • Awesome. I wish I had found this last year, when I spent quite some time on an issue related to this. – Devdatta Tengshe May 27 '14 at 6:59
  • Thank you for your answer @Mark C. I tried it, but it didn't work. Are these events still in the most recent version of OpenLayers? I can't find them in the code. First of all, I am using a minified version of OL2. I looked for the uncompressed version and a searched the files for "loadwarning" and "loadfail". I can't find these events. :s How did you implement this? Thank again. – joaorodr84 May 27 '14 at 11:48
  • @joaorodr84 I'm not using it currently, I implemented a ping to the tile server on a worker process. This came from some research I did after that time. I will look into it tomorrow. What I actually ended up doing did was to implement a ping in a HTML5 worker process to determine if the server was on line, assuming that if it was, it would deliver tiles. This allows me to display a status on the screen as off line on line. I will post that code as another alternative .. – Mark Cupitt May 27 '14 at 12:01
  • Well, upon further research (I love OL) this has different events (beforedraw, loadstart, loadend, loaderror, reload, unload). Go figure .. I guess they morphed the original code into this ?? – Mark Cupitt May 27 '14 at 12:31
  • @Devdatta Tengshe seems like it did not make it into mainstream Ol, but I found an update with loaderror event that might work. Have not tried it yet. (Answer Updated) – Mark Cupitt May 27 '14 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.