Thanks thenewbase = mapPanel.map.getLayersByName(thelayer)[0];
works ! Karsten > -----Original Message----- > From: christopher.schm...@nokia.com > [mailto:christopher.schm...@nokia.com] > Sent: Monday, September 19, 2011 19:22 > To: kars...@terragis.net > Cc: us...@openlayers.org > Subject: Re: [OpenLayers-Users] set base layer programatically > > getLayersByName returns an array of layers. You want to use something > like: > > thenewbase = mapPanel.map.getLayersByName(thelayer)[0]; > On Sep 19, 2011, at 10:10 PM, ext karsten vennemann wrote: > > > 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 > > _______________________________________________ > > Users mailing list > > us...@lists.osgeo.org > > http://lists.osgeo.org/mailman/listinfo/openlayers-users > > > > > > ======= > Email scanned by PC Tools - No viruses or spyware found. > (Email Guard: 7.0.0.21, Virus/Spyware Database: 6.18340) > http://www.pctools.com/ ======= _______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users