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

Maria Panagou snowdrop at ath.forthnet.gr
Sun Jan 13 13:47:14 EST 2008


I'm trying to display a different base layer, depending on zoom levels. I use
the following code:



 map.events.register("zoomend", map, function() {
			if (map.getZoom()>0) {
			   if (map.getNumLayers()<5) { 
		  		 map.addLayers([satellite, hybrid]);
          		 //map.setBaseLayer(satellite]);
          		map.removeLayer(nomoi);
          		    } 
				}
			else 
			{
			map.removeLayer(satellite);
			map.removeLayer(hybrid);
			map.addLayer(nomoi);
          	} 
		   });

the above works well when you zoom in and out the map, but if you get to the
extents of the map (zoomlevel:0) when else code executes, then if you try to
zoom again in the map, the code stops working and I see in Firefly that the
problem is:

this.pane has no properties
[Break on this error]  this.pane.style.zIndex =
parseInt(this.div.style.zIndex) + 1;

moreover when I try changing the baseLayer as well with

 //map.setBaseLayer(satellite]);

this works but the whole behavior of layer switcher is altered. I can't no
longer switch between different baselayers from layer switcher. when i click
on a layer, the whole map pans

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




More information about the Users mailing list