3

In OpenLayers I'm having a missing tile problem where it generates a missing link icon and a pink background. I found several threads including this one saying to add this code OpenLayers.Util.onImageLoadError = function() {this.src = '/img/blank.png';};

Sorry if this is dumb, but should my blank.png just be a 1px transparent png24? And also where should the img folder go?

Sorry, I've tried 1px, 256px, png24, png8, gif and putting the img folder and/or file in every conceivable place and I'm having no luck. Maybe you'll see something in these screenshots.

I've also tried an image with color to see if I can notice any actual change, so that's why the blank.png file looks red in the Finder thumbnail.

chrome code file structure

2
  • you don't need an image - it is just there to force the tile cache to get the 'real' images from Openlayers mobile - openlayers.org/dev/examples/mobile.html
    – Mapperz
    Jun 25, 2012 at 17:23
  • I'm sorry, I'm new to Open Layers. Could you please paste how this code should read? OpenLayers.Util.onImageLoadError = function() {this.src = '/img/blank.png';};
    – billted98
    Jun 25, 2012 at 18:45

1 Answer 1

5

Woohoo! Figured it out. This thread had the solution to change the CSS rather than the JS.

.olImageLoadError { 
    /* when OL encounters a 404, don't display the pink image */
    display: none !important;
}

This help article was helpful too, but I have not idea how to tell TileMill/MapBox to generate blank tiles rather than missing tiles. I'll get there someday.

2
  • TileMill will skip empty tiles; in map clients there's always a way to handle 404s somewhat gracefully and skipping tiles with no data is much more performant than rendering blank tiles everywhere.
    – tmcw
    Jun 26, 2012 at 17:26
  • Agreed. Any ideas are most surely welcome :) I haven't been able to figure it out so far.
    – billted98
    Jun 27, 2012 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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