Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.