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.

asked Apr 3, 2012 at 15:20

1 Answer 1

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";
};
answered Apr 3, 2012 at 15:31
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.