<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Eric, thanks for the fast reply.<br>
<br>
With the baseLayer-object it works. I tried to apply the method
directly to the layer, maybe that was the problem.<br>
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.<br>
If I do it like this:<br>
<br>
<font face="Courier New, Courier, monospace">var map = new
OpenLayers.Map(options);<br>
<br>
var google = new OpenLayers.Layer.Google(<br>
"Google",<br>
{'sphericalMercator': true}<br>
);<br>
<br>
var OSM = new OpenLayers.Layer.OSM("OSM");<br>
<br>
var google_t = new OpenLayers.Layer.Google(<br>
"Google_Terrain",<br>
{type: G_PHYSICAL_MAP, 'sphericalMercator': true}<br>
);<br>
<br>
map.addLayers([OSM, google, google_t]);<br>
<br>
map.baseLayer.setOpacity(0.5);</font><br>
<br>
the opacity is applied just to the initial baseLayer. The other layers
don't have a opacity after being selected.<br>
I think, thats why I have to trigger the event, wether a layer is
selected or not and set the opacity afterwards.<br>
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.<br>
If you or somebody else got a hint, I would appreciate it very much.<br>
<br>
Cheers<br>
Dirk.<br>
<br>
<br>
<br>
<br>
Eric Lemoine schrieb:
<blockquote
cite="mid:ca7da9121001132334n3c29d1eq41675e794620fd45@mail.gmail.com"
type="cite">
<pre wrap="">On Wed, Jan 13, 2010 at 7:05 PM, Dirk Tanneberger
<a class="moz-txt-link-rfc2396E" href="mailto:dirk.tanneberger@unibas.ch"><dirk.tanneberger@unibas.ch></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi everybody,
</pre>
</blockquote>
<pre wrap=""><!---->
Hi
</pre>
<blockquote type="cite">
<pre wrap="">I'm using Openlayers within MapFish. But I think the issue is specific
to Openlayers, so I post it here. Hope somebody got a clue.
What I'm trying to do is: applying a opacity to a Google-Layer with the
"setOpacity"-method.
Here is the code I'm using:
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(810690, 6027000,
883240, 6118400),
controls: []
};
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}
);
google.setOpacity(0.5);
map.addLayers([google, OSM, google_t]);
It works fine for th OSM-layer (if specified), but either one of the
Google-layers won't take the opacity. They just show up in full bright.
Has anybody experienced similar?
</pre>
</blockquote>
<pre wrap=""><!---->
No. I just opened
<a class="moz-txt-link-rfc2396E" href="http://openlayers.org/dev/examples/spherical-mercator.html"><http://openlayers.org/dev/examples/spherical-mercator.html></a> and
entered map.baseLayer.setOpacity(0.2) in the FireBug console and the
Google layer's opacity did change. Do you have a live example showing
the problem?
</pre>
<blockquote type="cite">
<pre wrap="">Another question is: How can I obtain the selected Layer from the map?
</pre>
</blockquote>
<pre wrap=""><!---->
map.baseLayer may be what you're looking for.
Cheers,
</pre>
</blockquote>
<br>
</body>
</html>