[OpenLayers-Users] scale dependent layers

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Fri Dec 7 09:53:41 EST 2007


Hi list,

I am trying to make one of my WMS layers scale dependent (only visible
between 0 and 1:25000, units: m), but I cannot get it done.

My map is constructed with an array of scales and a maxExtent.

On my layer I use minScale 25000 and maxScale 0.

But since the code in InitResolutions of Layer.js falls back on the map
object, the Layer's scales array will be set using the Map's scales array,
and the code for minScale and maxScale will never be reached.

I also tried putting in scales: null or scales: [] to the Layer constructor
but this did not help.

Any ideas? TIA.

My idea would be to pass in an empty scales array (scales: []), and to
change the following:

// First off, we take whatever hodge-podge of values we have and 
//  calculate/distill them down into a resolutions[] array
//
if ((confProps.scales != null) || (confProps.resolutions != null)) { 

to:

if (((confProps.scales != null) && (confProps.scales.length > 0)) ||
((confProps.resolutions != null) && (confProps.resolutions.length > 0))) { 

so it becomes possible to overrule the scales or resolutions array on the
layer.

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl








More information about the Users mailing list