[OpenLayers-Users] Overlays only at specific zoom levels

Derek Watling derek at cmainfo.co.za
Wed Oct 21 04:04:27 EDT 2009


I am using Google base layers in OpenLayers 2.8 with a my own WMS overlay
that is only avalilable at at the top 3 zoom levels. My bounding box is set
to cover South Africa. I have the Google zoom levels limited to between 5
and 18 with the following code:

    ...
    var bbox = new OpenLayers.Bounds(bbox = 1780677, -4180188, 3683653,
-2512026);
    var mapOptions = {
        projection: new OpenLayers.Projection("EPSG:900913"),
        units: 'm',
        maxResolution: 156543.0339,
        maxExtent: bbox,
        restrictedExtent: bbox
    };
    var map = new OpenLayers.Map('divMap', mapOptions);
    map.addControl(new OpenLayers.Control.LayerSwitcher());

    var gmap = new OpenLayers.Layer.Google("Google Streets", {
"sphericalMercator": true });
    gmap.MIN_ZOOM_LEVEL = 5;
    gmap.MAX_ZOOM_LEVEL = 18;

    var myOverlay = new OpenLayers.Layer.WMS(
        "Custom Overlay",
        "http://dev/Tilecache/tilecache.py?",
        { layers: "Custom", 'maxExtent': bbox, format: "image/png" }
    );
    myOverlay.setIsBaseLayer(false);
    myOverlay.displayOutsideMaxExtent = 0;
    myOverlay.transitionEffect = "resize";

    map.addLayers([gmap, myOverlay]);
    ....

How do I tell OpenLayers that myOverlay only exists for the following
resolutions?
2.38865713348388, 1.19432856674194, 0.597164283370971
Currently I get "pink" tiles overlayed where the tiles do not exist!

My tilecache.cfg is set up as follows:
[cache]
type=Disk
base=C:\Inetpub\TileCache\Cache

[Custom]
type=WMSLayer
bbox=-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892
#maxResolution=156543.0339
resolutions=2.38865713348388, 1.19432856674194, 0.597164283370971
srs=EPSG:900913
layers=Overlay,OverlayLabels
url=http://localhost/Mapping/WMS.aspx?Transparent=True&
extension=png
metaTile=yes
metaSize=5,5
mettaBuffer=0

-- 
View this message in context: http://n2.nabble.com/Overlays-only-at-specific-zoom-levels-tp3863769p3863769.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list