OpenLayers.Layer.Markers - propagate layer's opacity to the markers. Thanks

ahughes for the bug report and crschmidt for review and advices. (Closes #1114)



git-svn-id: http://svn.openlayers.org/trunk/openlayers@5509 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2007-12-19 15:00:49 +00:00
parent 6fb48c0cd7
commit e3406bf095
3 changed files with 53 additions and 1 deletions

View File

@@ -29,6 +29,12 @@ OpenLayers.Layer = OpenLayers.Class({
*/
div: null,
/**
* Property: opacity
* {Float} The layer's opacity. Float number between 0.0 and 1.0.
*/
opacity: null,
/**
* Constant: EVENT_TYPES
* {Array(String)} Supported application event types

View File

@@ -57,7 +57,22 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/**
* APIMethod: setOpacity
* Sets the opacity for all the markers.
*
* Parameter:
* opacity - {Float}
*/
setOpacity: function(opacity) {
if (opacity != this.opacity) {
this.opacity = opacity;
for (var i = 0; i < this.markers.length; i++) {
this.markers[i].setOpacity(this.opacity);
}
}
},
/**
* Method: moveTo
*
@@ -85,6 +100,11 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
*/
addMarker: function(marker) {
this.markers.push(marker);
if (this.opacity != null) {
marker.setOpacity(this.opacity);
}
if (this.map && this.map.getExtent()) {
marker.map = this.map;
this.drawMarker(marker);