[OpenLayers-Users] Overlays only at specific zoom levels

Derek Watling derek at cmainfo.co.za
Fri Oct 30 02:57:55 EDT 2009


Hi Eric

I had tried setting the resolutions as part of the "params" in the
constructor:

     var myOverlay = new OpenLayers.Layer.WMS(
         "Custom Overlay",
         "http://dev/Tilecache/tilecache.py?",
         { layers: "Custom",
            'maxExtent': bbox,
            format: "image/png",
            resolutions: [2.388657133483887, 1.19432856674194,
0.597164283370971]
         }
     );

However, if I move it to the "options" it works:

     var myOverlay = new OpenLayers.Layer.WMS(
         "Custom Overlay",
         "http://dev/Tilecache/tilecache.py?",
         { layers: "Custom",
            'maxExtent': bbox,
            format: "image/png"
         },
         { resolutions: [2.388657133483887, 1.19432856674194,
0.597164283370971] }
     );

but this introduces an issue with IE 8 in that the "Google" image doesn't
update when changing base layers!

I have found a hack that makes it work: By changing the size of the map when
the base layer changes IE 8 renders the new layer:

        map.events.register('changebaselayer', null, function(e) {
            var pnlMap = document.getElementById("pnlMap");
            pnlMap.style.height = (parseInt(pnlMap.style.height) - 1) +
'px';
            setTimeout("pnlMap.style.height = (parseInt(pnlMap.style.height)
+ 1) + 'px'", 500);
        });

where "pnlMap" is a <div> around my "mapDiv".

If anyone has a more elegant solution, it would be appreciated.


Eric Lemoine-2-2 wrote:
> 
> 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.
> 

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



More information about the Users mailing list