UrlTemplateImageryProvider and tileDiscardPolicy?

I’ve successfully created a UrlTemplateImageryProvider, but the layer (by design) does not include image files for areas of the globe for which it has no data.

It’s working fine, but I get a ton of errors in the console about the missing files.

I checked the docs, and there’s a (read-only) member called “tileDiscardPolicy” which looks like it should have something to do with it, but the documentation is slim.

Digging into the source, it appears that I can create my own tileDiscardPolicy and pass it in as an option, but this is undocumented.

Is there a way I can prevent the (spurious) errors from polluting the console?

See my demo project here:




Hello Dave,

So the TileDiscardPolicy is more for defining a function to filter out tiles when the image returned is ‘bad’. It can’t be used to get around the errors being returned for missing files.

Do you know the bounds of the tile set you are using? You can use the minimumLevel, maximumLevel and rectangle options to make sure the UrlTemplateImageryProvider doesn’t try to retrieve tiles you know don’t exist.