Search code examples
gisopenlayers

OpenLayers: Load cached tiles only if present, otherwise get them online


I have two layers, OpenStreetMap for online tiles and TMS for cached tiles from a different tile source. I know how to display each of the layers separately.

However, TMS does not contain all the tiles. So I would like to display TMS tiles first and then everything else that is not cached with OpenStreetMap. How could I do this overlapping of two layers?

The result should look just like below: a busy cat http://tothchat.com/test/tiles.png


Solution

  • This two layers must be overlay (not baseLayer). Did you try this:

    map = new OpenLayers.Map({
            div: "map",
            allOverlays: true  //<- all layers will have isBaseLayer set to false when they are added to the map.
        });
    

    Or set isBaseLayer parameter to false for these two layers.