2

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.

3

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";
};

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.