diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 5631d8a83f..1b9f75d59d 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -65,6 +65,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") { "OpenLayers/Feature/WFS.js", "OpenLayers/Tile/Image.js", "OpenLayers/Tile/WFS.js", + "OpenLayers/Layer/EventPane.js", "OpenLayers/Layer/Google.js", "OpenLayers/Layer/VirtualEarth.js", // "OpenLayers/Layer/Yahoo.js", diff --git a/lib/OpenLayers/Layer/EventPane.js b/lib/OpenLayers/Layer/EventPane.js index 67ac560149..5c49086351 100644 --- a/lib/OpenLayers/Layer/EventPane.js +++ b/lib/OpenLayers/Layer/EventPane.js @@ -6,6 +6,21 @@ */ OpenLayers.Layer.EventPane = Class.create(); OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, { + /** EventPaned layers are always base layers, by necessity. + * @type Boolean + */ + isBaseLayer: true, + + /** EventPaned layers are fixed by default. + * @type Boolean + */ + isFixed: true, + + /** + * @type HTMLDOMElement + */ + pane: null, + /** * @constructor * @@ -14,46 +29,16 @@ OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, { */ initialize: function(name, options) { if (arguments.length > 0) { - - //store a copy of the custom options for later cloning - this.options = Object.extend(new Object(), options); - - //add options to layer - Object.extend(this, this.options); - - this.name = name; - - //generate unique id based on name - this.id = OpenLayers.Util.createUniqueID("Layer_"); - - if (this.div == null) { - this.div = OpenLayers.Util.createDiv(); - this.div.style.width = "100%"; - this.div.style.height = "100%"; + OpenLayers.Layer.prototype.initialize.apply(this, arguments); + if (this.pane == null) { + this.pane = OpenLayers.Util.createDiv(); + this.pane.style.width = "100%"; + this.pane.style.height = "100%"; + this.pane.style.backgroundColor = "transparent"; } } }, - /** - * @returns An exact clone of this OpenLayers.Layer - * @type OpenLayers.Layer - */ - clone: function (obj) { - - if (obj == null) { - obj = new OpenLayers.Layer(this.name, this.options); - } - - // catch any randomly tagged-on properties - obj = OpenLayers.Util.applyDefaults(obj, this); - - // a cloned layer should never have its map property set - // because it has not been added to a map yet. - obj.map = null; - - return obj; - }, - /** Set the map property for the layer. This is done through an accessor * so that subclasses can override this and take special action once * they have their map variable set. @@ -61,21 +46,15 @@ OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, { * @param {OpenLayers.Map} map */ setMap: function(map) { - this.map = map; - - var properties = new Array( - 'projection', 'minExtent', 'maxExtent', - 'minScale', 'maxScale', - 'maxResolution', 'minResolution', - 'minZoomLevel', 'maxZoomLevel', 'units', - 'scales', 'resolutions' - - ); - for(var i=0; i < properties.length; i++) { - if (this[properties[i]] == null) { - this[properties[i]] = this.map[properties[i]]; - } + OpenLayers.Layer.prototype.setMap.apply(this, arguments); + this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1; + this.pane.style.display = this.div.style.display; + if (this.isFixed) { + this.map.viewPortDiv.appendChild(this.pane); + } else { + this.map.layerContainerDiv.appendChild(this.pane); } + this.map.events.attachToElement(this.pane); }, /** @@ -83,19 +62,8 @@ OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, { * @param {Boolean} noEvent */ setVisibility: function(visible, noEvent) { - if (visible != this.getVisibility()) { - this.div.style.display = (visible) ? "block" : "none"; - if ((visible) && (this.map != null)) { - var extent = this.map.getExtent(); - if (extent != null) { - this.moveTo(this.map.getExtent()); - } - } - if ((this.map != null) && - ((noEvent == null) || (noEvent == false))) { - this.map.events.triggerEvent("changelayer"); - } - } + OpenLayers.Layer.prototype.setVisibility.apply(this, arguments); + this.pane.style.display = this.div.style.display; }, /** @final @type String */