Raise layer that's being modified
This commit is contained in:
@@ -277,6 +277,13 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Take care of things that are not handled in superclass.
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.map) {
|
||||
this.map.events.un({
|
||||
"removelayer": this.handleMapEvents,
|
||||
"changelayer": this.handleMapEvents,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
this.layer = null;
|
||||
OpenLayers.Control.prototype.destroy.apply(this, []);
|
||||
},
|
||||
@@ -289,6 +296,12 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Boolean} Successfully activated the control.
|
||||
*/
|
||||
activate: function() {
|
||||
this.moveLayerToTop();
|
||||
this.map.events.on({
|
||||
"removelayer": this.handleMapEvents,
|
||||
"changelayer": this.handleMapEvents,
|
||||
scope: this
|
||||
});
|
||||
return (this.handlers.keyboard.activate() &&
|
||||
this.handlers.drag.activate() &&
|
||||
OpenLayers.Control.prototype.activate.apply(this, arguments));
|
||||
@@ -305,6 +318,12 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var deactivated = false;
|
||||
// the return from the controls is unimportant in this case
|
||||
if(OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {
|
||||
this.moveLayerBack();
|
||||
this.map.events.un({
|
||||
"removelayer": this.handleMapEvents,
|
||||
"changelayer": this.handleMapEvents,
|
||||
scope: this
|
||||
});
|
||||
this.layer.removeFeatures(this.vertices, {silent: true});
|
||||
this.layer.removeFeatures(this.virtualVertices, {silent: true});
|
||||
this.vertices = [];
|
||||
@@ -750,6 +769,45 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: handleMapEvents
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object}
|
||||
*/
|
||||
handleMapEvents: function(evt) {
|
||||
if (evt.type == "removelayer" || 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.Control.ModifyFeature"
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user