Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to detect when loading tiles has failed?

Is there a way to detect when the tile server cannot be contacted with OpenLayers? I want to display a "Tile server cannot be found" failure message instead of just those ugly "image not found" red X tiles.

like image 317
John Leehey Avatar asked Dec 13 '25 15:12

John Leehey


1 Answers

Just as an FYI to anyone who needs to do this, I solved this with the following code (placed BEFORE I created my map, layers, etc.):

OpenLayers.Util.onImageLoadError = function () {
    this.src = "images/noTile.png";
}

where images/noTile.png was the image I used as the "Tile not found" image.

like image 99
John Leehey Avatar answered Dec 15 '25 05:12

John Leehey