[OpenLayers-Users] How to show "nothing" when a tile is not found with TileCache

Tim Schaub tschaub at opengeo.org
Tue Jun 23 13:19:26 EDT 2009


Hey-

Linde Ackermans wrote:
> Hi all,
> 
> I defined my layers with OpenLayers.TileCache
> 
> f.i. 
> 	var l1= new OpenLayers.Layer.TileCache("xxx", 
>             ["http://xx.xx.xx.xx/tilecache/cache/",
>              "l1",
>              {scales: Scales, resolutions: Resolutions,
>               buffer:0, format:"image/png", isBaseLayer:false},
>              );
> 
> Say I have a base layer l0, extent = europe.
> I want to overlay l1, but this layer only contains detailed information on
> capital cities, on a very high scale.
> I do not want to make a cache for layer l1 for the whole extent of the base
> layer ( would be too much ), but only for a few selected rectangles.
> How can I do this ? How can I show "nothing" for tiles not found ? ( Or an
> empty tile which is transparent ? )

The default behavior is to turn tiles pink if no image is returned.

OpenLayers.Util.onImageLoadErrorColor = "pink";

If your service doesn't return an image in certain areas and you want 
those to be transparent in the client, use the following:

OpenLayers.Util.onImageLoadErrorColor = "transparent";

(Set this property before you set your map center.)

Tim

> Thanks for any help.
> Linde
> 


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Users mailing list