[OpenLayers-Users] switch basemaps prgramaticaly

Bart van den Eijnden bartvde at osgis.nl
Wed Jun 30 08:16:31 EDT 2010


Use setBaseLayer on the map object.

Best regards,
Bart

On Jun 30, 2010, at 2:14 PM, Imran Rajjad wrote:

> Hi list,
> 
> How do you programtically switch between base map layers such that the
> radio button for the visibile is checked. I tried using setVisbility
> and getVisibility, that works fine but when you pan or zoom there is
> no change and no new tiles are loaded, just as you click the radio
> buttons everything starts working.
> 
> I have writen a function that does that but its not good enough
> 
> function copyLayerVisblity(layerName)
> {
> 	try{
> 	var source=opener.map.getLayersByName(layerName);
> 	var target=map.getLayersByName(layerName);
> 
> 	target[0].setVisibility(source[0].getVisibility());
> 	
> 	}catch(e)
> 	{
> 	console.log(layerName+" does not exist in either parent or child window")
> 	}
> }
> 
> -- 
> I.R
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 




More information about the Users mailing list