[OpenLayers-Users] set base layer programatically
karsten vennemann
karsten at terragis.net
Mon Sep 19 23:36:08 EDT 2011
Thanks
thenewbase = mapPanel.map.getLayersByName(thelayer)[0];
works !
Karsten
> -----Original Message-----
> From: christopher.schmidt at nokia.com
> [mailto:christopher.schmidt at nokia.com]
> Sent: Monday, September 19, 2011 19:22
> To: karsten at terragis.net
> Cc: users at 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
> > Users at 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/ =======
More information about the Users
mailing list