diff --git a/lib/OpenLayers/Layer/Google.js b/lib/OpenLayers/Layer/Google.js index 9dd8b01152..71bcdcc2a7 100644 --- a/lib/OpenLayers/Layer/Google.js +++ b/lib/OpenLayers/Layer/Google.js @@ -263,7 +263,10 @@ OpenLayers.Layer.Google = OpenLayers.Class( */ setVisibility: function(visible) { this.setGMapVisibility(visible); + // sharing a map container, opacity has to be set per layer + var opacity = this.opacity == null ? 1 : this.opacity; OpenLayers.Layer.EventPane.prototype.setVisibility.apply(this, arguments); + this.setOpacity(opacity); }, /** @@ -303,6 +306,33 @@ OpenLayers.Layer.Google = OpenLayers.Class( } }, + /** + * APIMethod: setOpacity + * Sets the opacity for the entire layer (all images) + * + * Parameter: + * opacity - {Float} + */ + setOpacity: function(opacity) { + if (opacity !== this.opacity) { + if (this.map != null) { + this.map.events.triggerEvent("changelayer", { + layer: this, + property: "opacity" + }); + } + this.opacity = opacity; + } + // Though this layer's opacity may not change, we're sharing a container + // and need to update the opacity for the entire container. + if (this.getVisibility()) { + var container = this.mapObject.getContainer(); + OpenLayers.Util.modifyDOMElement( + container, null, null, null, null, null, null, opacity + ); + } + }, + /** * APIMethod: destroy * Clean up this layer. diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index abd47d1dd8..82e801e868 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -424,9 +424,9 @@ OpenLayers.Map = OpenLayers.Class({ * ways to call the map constructor. See the examples below. * * Parameters: - * div - {String} Id of an element in your page that will contain the map. - * May be omitted if the