ModifyFeature makes SelectFeature control behave/become like ModifyFeature, patch=bjornharrtell,tschaub, r=tschaub,me (closes #1741)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8302 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2008-11-07 08:46:02 +00:00
parent d82f73e9e7
commit 7c0fadd14a
3 changed files with 51 additions and 45 deletions

View File

@@ -195,17 +195,15 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
var selectOptions = {
geometryTypes: this.geometryTypes,
clickout: this.clickout,
toggle: this.toggle
toggle: this.toggle,
onBeforeSelect: this.beforeSelectFeature,
onSelect: this.selectFeature,
onUnselect: this.unselectFeature,
scope: this
};
this.selectControl = new OpenLayers.Control.SelectFeature(
layer, selectOptions
);
this.layer.events.on({
"beforefeatureselected": this.beforeSelectFeature,
"featureselected": this.selectFeature,
"featureunselected": this.unselectFeature,
scope: this
});
// configure the drag control
var dragOptions = {
@@ -239,12 +237,6 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Take care of things that are not handled in superclass.
*/
destroy: function() {
this.layer.events.un({
"beforefeatureselected": this.beforeSelectFeature,
"featureselected": this.selectFeature,
"featureunselected": this.unselectFeature,
scope: this
});
this.layer = null;
this.selectControl.destroy();
this.dragControl.destroy();
@@ -295,12 +287,11 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Called before a feature is selected.
*
* Parameters:
* object - {Object} Object with a feature property referencing the
* selected feature.
* feature - {<OpenLayers.Feature.Vector>} The feature about to be selected.
*/
beforeSelectFeature: function(object) {
beforeSelectFeature: function(feature) {
return this.layer.events.triggerEvent(
"beforefeaturemodified", {feature: object.feature}
"beforefeaturemodified", {feature: feature}
);
},
@@ -309,11 +300,10 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Called when the select feature control selects a feature.
*
* Parameters:
* object - {Object} Object with a feature property referencing the
* selected feature.
* feature - {<OpenLayers.Feature.Vector>} the selected feature.
*/
selectFeature: function(object) {
this.feature = object.feature;
selectFeature: function(feature) {
this.feature = feature;
this.resetVertices();
this.dragControl.activate();
this.onModificationStart(this.feature);
@@ -324,10 +314,9 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Called when the select feature control unselects a feature.
*
* Parameters:
* object - {Object} Object with a feature property referencing the
* unselected feature.
* feature - {<OpenLayers.Feature.Vector>} The unselected feature.
*/
unselectFeature: function(object) {
unselectFeature: function(feature) {
this.layer.removeFeatures(this.vertices, {silent: true});
this.vertices = [];
this.layer.destroyFeatures(this.virtualVertices, {silent: true});
@@ -342,9 +331,9 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
}
this.feature = null;
this.dragControl.deactivate();
this.onModificationEnd(object.feature);
this.onModificationEnd(feature);
this.layer.events.triggerEvent("afterfeaturemodified",
{feature: object.feature});
{feature: feature});
},
/**