Trigger feature related events with feature information and layer related events with layer information. Also adding events.on and events.un convenience methods. r=crschmidt (closes #1343)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6149 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-02-08 23:31:27 +00:00
parent 464fb30589
commit f27833f1db
20 changed files with 326 additions and 118 deletions

View File

@@ -182,17 +182,16 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
var selectOptions = {
geometryTypes: this.geometryTypes,
clickout: this.clickout,
toggle: this.toggle,
onSelect: function(feature) {
control.selectFeature.apply(control, [feature]);
},
onUnselect: function(feature) {
control.unselectFeature.apply(control, [feature]);
}
toggle: this.toggle
};
this.selectControl = new OpenLayers.Control.SelectFeature(
layer, selectOptions
);
this.layer.events.on({
"featureselected": this.selectFeature,
"featureunselected": this.unselectFeature,
scope: this
});
// configure the drag control
var dragOptions = {
@@ -226,6 +225,11 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Take care of things that are not handled in superclass.
*/
destroy: function() {
this.layer.events.un({
"featureselected": this.selectFeature,
"featureunselected": this.unselectFeature,
scope: this
});
this.layer = null;
this.selectControl.destroy();
this.dragControl.destroy();
@@ -276,10 +280,11 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Called when the select feature control selects a feature.
*
* Parameters:
* feature - {<OpenLayers.Feature.Vector>} The selected feature.
* object - {Object} Object with a feature property referencing the
* selected feature.
*/
selectFeature: function(feature) {
this.feature = feature;
selectFeature: function(object) {
this.feature = object.feature;
this.resetVertices();
this.dragControl.activate();
this.onModificationStart(this.feature);
@@ -290,9 +295,10 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
* Called when the select feature control unselects a feature.
*
* Parameters:
* feature - {<OpenLayers.Feature.Vector>} The unselected feature.
* object - {Object} Object with a feature property referencing the
* unselected feature.
*/
unselectFeature: function(feature) {
unselectFeature: function(object) {
this.layer.removeFeatures(this.vertices);
this.vertices = [];
this.layer.destroyFeatures(this.virtualVertices);
@@ -307,7 +313,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
}
this.feature = null;
this.dragControl.deactivate();
this.onModificationEnd(feature);
this.onModificationEnd(object.feature);
},
/**