Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In OpenLayers, when a tile is missing in a TMS layer, a semi-transparent pink rectangle shows in its place. Is there a way to load some default image, like one saying "No data for this region under this zoom" instead?

One possibility is to request the tiles through something like a PHP script or a Java servlet. If a nonexistent tile is requested, this servlet would then send the default tile.

However, I'm currently taking the tiles directly from the filesystem, so I'm looking for a solution to be done only with JS / OpenLayers.

share|improve this question
up vote 3 down vote accepted

You can try this:

OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5; // this will help in avoiding the pink tiles in the first place.
OpenLayers.Util.onImageLoadError = function(){
     this.src = "images/yourImage.png";
share|improve this answer
Yes, that's what I meant. Thanks ;) – Imp Apr 3 '12 at 15:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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