[OpenLayers-Users] set base layer programatically
christopher.schmidt at nokia.com
christopher.schmidt at nokia.com
Mon Sep 19 22:22:01 EDT 2011
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
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
More information about the Users
mailing list