[OpenLayers-Users] Opacity of GoogleLayer, get selected layer
Dirk Tanneberger
dirk.tanneberger at unibas.ch
Fri Jan 15 12:14:45 EST 2010
Eric Lemoine schrieb:
> On Fri, Jan 15, 2010 at 12:05 PM, Dirk Tanneberger
> <dirk.tanneberger at unibas.ch> wrote:
>
>> Hi Eric, thanks for the fast reply.
>>
>> With the baseLayer-object it works. I tried to apply the method directly to
>> the layer, maybe that was the problem.
>> But still I have the problem, when changing the baseLayer. In my case I got
>> three baseLayers and no matter which one is selected it should have a
>> opacity.
>> If I do it like this:
>>
>> var map = new OpenLayers.Map(options);
>>
>> var google = new OpenLayers.Layer.Google(
>> "Google",
>> {'sphericalMercator': true}
>> );
>>
>> var OSM = new OpenLayers.Layer.OSM("OSM");
>>
>> var google_t = new OpenLayers.Layer.Google(
>> "Google_Terrain",
>> {type: G_PHYSICAL_MAP, 'sphericalMercator': true}
>> );
>>
>> map.addLayers([OSM, google, google_t]);
>>
>> map.baseLayer.setOpacity(0.5);
>>
>> the opacity is applied just to the initial baseLayer. The other layers don't
>> have a opacity after being selected.
>> I think, thats why I have to trigger the event, wether a layer is selected
>> or not and set the opacity afterwards.
>> Maybe it is possible to do so in the treepanel-object of the mapFish-API.
>> Couldn't find anything appropriate so far, but I have to dig more into it.
>> If you or somebody else got a hint, I would appreciate it very much.
>>
>
> <http://www.openlayers.org/dev/examples/spherical-mercator.html>
>
> open the firebug console, and do:
>
> map.layers[0].setOpacity(0.2) // -> this changes the opacity of the
> current base layer
> map.layers[1].setOpacity(0.2) // -> this changes the opacity of the
> Google Satellite layer, although it's not the current base layer
>
> now select the Google Satellite layer in the LayerSwitcher, its
> opacity is expectedly 0.2.
>
> Maybe I don't understand the issue you're having.
>
>
Alright, that works.
I thought, I can do it dynamicly. Set the opacity of a layer just after
it is selected. But to do it initially for every layer, is fine for the
moment.
Merci
Dirk.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100115/ed28bdc4/attachment.html
More information about the Users
mailing list