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

Attila Csipa plists at prometheus.org.yu
Mon Jan 14 18:39:18 EST 2008


On Monday 14 January 2008 23:33:04 Maria Panagou wrote:
> 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?

It's a context, think about it as who will get notified if an event happens 
(in our case, map will call our function in the context of satellite if map 
gets to be zoomed - the event is still map's event so to speak). Layers don't 
even have zoom related events, that's OpenLayers.Map territorry. It doesn't 
matter if it's not visible and not in the layerswitcher, it's still in the 
map object and will get called accordingly - which is exactly what you want, 
If I'm not mistaken. This way you can register several layers, and set up 
logic for each layer how it will react to a change in the zoomlevel. I'm 
fairly new at this myself, but that's how I already did a couple of maps and 
it works nicely. If any of the more experienced OL users feel I got it wrong 
or that the comment is misleading, speak up, in that case I'm interested in 
suggestions, too :)





More information about the Users mailing list