[OpenLayers-Users] add, remove base layers depending on zoom, change baselayer

Maria Panagou snowdrop at ath.forthnet.gr
Mon Jan 14 17:33:04 EST 2008


Yes, but if refer to satellite layer in this way, wouldn't that mean that
when I zoom in that layer, something will happen? I really want something to
happen (display/hide layers) when I zoom in the map generally. At
initialization of map, layer satellite is hidden and off the layerswitcher
so, if i understand this properly 

map.events.register("zoomend", satellite, function(){,

will have no effect, as i'm not going to zoom in this layer. Am I wrong?
maybe i haven't completely understood when zoomend triggers...





Attila Csipa wrote:
> 
> 
> 
> From what I've seen in the examples you should use context properly, eg.
> in 
> your case, since you want to change layers:
> 
> map.events.register("zoomend", satellite, function(){
> 
> and then refer to satellite as this, so your calls would  look like 
> 
> this.displayInLayerSwitcher=false;
> this.map.setBaseLayer... etc
> 
> You should avoid using global variables as much as possible to avoid
> confusion 
> as to what your context is at the moment (context related errors are 
> especially nasty as they are in essence logical errors and thus won't be 
> always obvious in firebug). This might not be the root of your problems,
> but 
> it did bite me a couple of times so you should clear that up, just in
> case, 
> YMMV. 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://www.nabble.com/add%2C-remove-base-layers-depending-on-zoom%2C-change-baselayer-tp14789355p14817411.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list