[OpenLayers-Users] set base layer programatically

karsten vennemann karsten at terragis.net
Mon Sep 19 22:10:40 EDT 2011


I am trying to set the base layer inside a function like this
 
function switchbaselayer(newname) {
      var thelayer = newname;
      var thenewbase = mapPanel.map.getLayersByName(thelayer);
      mapPanel.map.setBaseLayer(thenewbase);
      mapPanel.map.baseLayer.setVisibility(true);
}
 
The cods seems to run through without any errors, however the base layer is not switched and the map not updated ( I can see that the layer object is found in getLayersByName). 
and in Firebug
mapPanel.map.baseLayer.name; 
prints the previous/old baselayers name 
 
What am I doing wrong ?
 
Cheers
Karsten 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110919/7bf0b18a/attachment.html


More information about the Users mailing list