[OpenLayers-Users] Activate/Deactivate layer by ZOOM LEVEL

BMcBride bmcbride at chacompanies.com
Wed Jun 16 11:52:20 EDT 2010


There are several options for handling this, depending on what you mean by
"activate".  If you mean layer visibility, you can set maxScale and minScale
parameters when you set up the layer.  You can also set scale rules in your
SLD file by using the <MinScaleDenominator> and <MaxScaleDenominator> tags. 
This will show/hide your layer features at the defined scale thresholds, but
will not change the checkbox state in the layerswitcher.

If you need to actually control layer toggling, you could set a zoomend
event listener and set your layer visibility.  See example below...

map.events.register('zoomend', this, function() {
if (map.getScale() > 30000)
{
layername.setVisibility(false);
}
});

-----
Bryan R. McBride, GISP
http://www.bryanmcbride.com bryanmcbride.com 
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Activate-Deactivate-layer-by-ZOOM-LEVEL-tp5186975p5187105.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list