[OpenLayers-Users] Opacity of GoogleLayer, get selected layer

Dirk Tanneberger dirk.tanneberger at unibas.ch
Wed Jan 13 13:05:30 EST 2010


Hi everybody,

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?


Another question is: How can I obtain the selected Layer from the map? I 
was looking for a method on the map- or layer-object, like 
"selectedLayer" or "isSelectedLayer". But I couldn't find any in the API.
I would like use it to change the appearence of a layer after it is 
selected.

Thanks very much for any hints.




Best regards, Dirk.




More information about the Users mailing list