Made the Feature handler more robust to things that are related to changing layer order on the map, by registering an event handler that will bring the handler's layer back to the top of the layer stack in the DOM. Contains a manual test. r=elemoine (closes #1628)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7879 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-08-27 14:02:21 +00:00
parent 8e0876488b
commit 2a521ffcb2
5 changed files with 218 additions and 20 deletions

View File

@@ -99,12 +99,6 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {
* value of stopUp. Defaults to false.
*/
stopUp: false,
/**
* Property: layerIndex
* {Int}
*/
layerIndex: null,
/**
* Constructor: OpenLayers.Handler.Feature
@@ -300,16 +294,20 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {
activate: function() {
var activated = false;
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
this.layerIndex = this.layer.div.style.zIndex;
this.layer.div.style.zIndex = this.map.Z_INDEX_BASE['Popup'] - 1;
this.moveLayerToTop();
this.map.events.on({
"removelayer": this.handleMapEvents,
"changelayer": this.handleMapEvents,
scope: this
});
activated = true;
}
return activated;
},
/**
* Method: activate
* Turn of the handler. Returns false if the handler was already active.
* Method: deactivate
* Turn off the handler. Returns false if the handler was already active.
*
* Returns:
* {Boolean}
@@ -317,17 +315,59 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {
deactivate: function() {
var deactivated = false;
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
if (this.layer && this.layer.div) {
this.layer.div.style.zIndex = this.layerIndex;
}
this.moveLayerBack();
this.feature = null;
this.lastFeature = null;
this.down = null;
this.up = null;
this.map.events.un({
"removelayer": this.handleMapEvents,
"changelayer": this.handleMapEvents,
scope: this
});
deactivated = true;
}
return deactivated;
},
/**
* Method handleMapEvents
*
* Parameters:
* evt - {Object}
*/
handleMapEvents: function(evt) {
if (!evt.property || evt.property == "order") {
this.moveLayerToTop();
}
},
/**
* Method: moveLayerToTop
* Moves the layer for this handler to the top, so mouse events can reach
* it.
*/
moveLayerToTop: function() {
var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,
this.layer.getZIndex()) + 1;
this.layer.setZIndex(index);
},
/**
* Method: moveLayerBack
* Moves the layer back to the position determined by the map's layers
* array.
*/
moveLayerBack: function() {
var index = this.layer.getZIndex() - 1;
if (index >= this.map.Z_INDEX_BASE['Feature']) {
this.layer.setZIndex(index);
} else {
this.map.setLayerZIndex(this.layer,
this.map.getLayerIndex(this.layer));
}
},
CLASS_NAME: "OpenLayers.Handler.Feature"
});