EventPane now works -- puts a transparent pane over a layer and passes events through it down to the map.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1193 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -65,6 +65,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
|||||||
"OpenLayers/Feature/WFS.js",
|
"OpenLayers/Feature/WFS.js",
|
||||||
"OpenLayers/Tile/Image.js",
|
"OpenLayers/Tile/Image.js",
|
||||||
"OpenLayers/Tile/WFS.js",
|
"OpenLayers/Tile/WFS.js",
|
||||||
|
"OpenLayers/Layer/EventPane.js",
|
||||||
"OpenLayers/Layer/Google.js",
|
"OpenLayers/Layer/Google.js",
|
||||||
"OpenLayers/Layer/VirtualEarth.js",
|
"OpenLayers/Layer/VirtualEarth.js",
|
||||||
// "OpenLayers/Layer/Yahoo.js",
|
// "OpenLayers/Layer/Yahoo.js",
|
||||||
|
|||||||
@@ -6,6 +6,21 @@
|
|||||||
*/
|
*/
|
||||||
OpenLayers.Layer.EventPane = Class.create();
|
OpenLayers.Layer.EventPane = Class.create();
|
||||||
OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, {
|
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
|
* @constructor
|
||||||
*
|
*
|
||||||
@@ -14,46 +29,16 @@ OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, {
|
|||||||
*/
|
*/
|
||||||
initialize: function(name, options) {
|
initialize: function(name, options) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
|
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||||
//store a copy of the custom options for later cloning
|
if (this.pane == null) {
|
||||||
this.options = Object.extend(new Object(), options);
|
this.pane = OpenLayers.Util.createDiv();
|
||||||
|
this.pane.style.width = "100%";
|
||||||
//add options to layer
|
this.pane.style.height = "100%";
|
||||||
Object.extend(this, this.options);
|
this.pane.style.backgroundColor = "transparent";
|
||||||
|
|
||||||
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%";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
/** Set the map property for the layer. This is done through an accessor
|
||||||
* so that subclasses can override this and take special action once
|
* so that subclasses can override this and take special action once
|
||||||
* they have their map variable set.
|
* they have their map variable set.
|
||||||
@@ -61,21 +46,15 @@ OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, {
|
|||||||
* @param {OpenLayers.Map} map
|
* @param {OpenLayers.Map} map
|
||||||
*/
|
*/
|
||||||
setMap: function(map) {
|
setMap: function(map) {
|
||||||
this.map = map;
|
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||||
|
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
|
||||||
var properties = new Array(
|
this.pane.style.display = this.div.style.display;
|
||||||
'projection', 'minExtent', 'maxExtent',
|
if (this.isFixed) {
|
||||||
'minScale', 'maxScale',
|
this.map.viewPortDiv.appendChild(this.pane);
|
||||||
'maxResolution', 'minResolution',
|
} else {
|
||||||
'minZoomLevel', 'maxZoomLevel', 'units',
|
this.map.layerContainerDiv.appendChild(this.pane);
|
||||||
'scales', 'resolutions'
|
|
||||||
|
|
||||||
);
|
|
||||||
for(var i=0; i < properties.length; i++) {
|
|
||||||
if (this[properties[i]] == null) {
|
|
||||||
this[properties[i]] = this.map[properties[i]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
this.map.events.attachToElement(this.pane);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,19 +62,8 @@ OpenLayers.Layer.EventPane.prototype = Object.extend(new OpenLayers.Layer, {
|
|||||||
* @param {Boolean} noEvent
|
* @param {Boolean} noEvent
|
||||||
*/
|
*/
|
||||||
setVisibility: function(visible, noEvent) {
|
setVisibility: function(visible, noEvent) {
|
||||||
if (visible != this.getVisibility()) {
|
OpenLayers.Layer.prototype.setVisibility.apply(this, arguments);
|
||||||
this.div.style.display = (visible) ? "block" : "none";
|
this.pane.style.display = this.div.style.display;
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
|
|||||||
Reference in New Issue
Block a user