[OpenLayers-Users] Overlays only at specific zoom levels

Eric Lemoine eric.lemoine at camptocamp.com
Thu Oct 29 13:14:35 EDT 2009


On Wednesday, October 21, 2009, Derek Watling <derek at cmainfo.co.za> wrote:
>
> 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

have you tried passing these resolutions to youe WMS layer, through
the "resolutions" config option. It should make OpenLayers "stop" the
layer when it's out of range.

Cheers,

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list