give Layer.Vector a vertexremoved event, to be fired e.g. by the ModifyFeature control. r=bartvde (closes #3017)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11043 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -608,6 +608,11 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
vertex.geometry.parent) {
|
vertex.geometry.parent) {
|
||||||
// remove the vertex
|
// remove the vertex
|
||||||
vertex.geometry.parent.removeComponent(vertex.geometry);
|
vertex.geometry.parent.removeComponent(vertex.geometry);
|
||||||
|
this.layer.events.triggerEvent("vertexremoved", {
|
||||||
|
vertex: vertex.geometry,
|
||||||
|
feature: this.feature,
|
||||||
|
pixel: evt.xy
|
||||||
|
});
|
||||||
this.layer.drawFeature(this.feature, this.standalone ?
|
this.layer.drawFeature(this.feature, this.standalone ?
|
||||||
undefined :
|
undefined :
|
||||||
this.selectControl.renderIntent);
|
this.selectControl.renderIntent);
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
* property referencing the vertex modified (always a point geometry),
|
* property referencing the vertex modified (always a point geometry),
|
||||||
* and a *pixel* property referencing the pixel location of the
|
* and a *pixel* property referencing the pixel location of the
|
||||||
* modification.
|
* modification.
|
||||||
|
* vertexremoved - Triggered when a vertex within any feature geometry
|
||||||
|
* has been deleted. Listeners will receive an object with a
|
||||||
|
* *feature* property referencing the modified feature, a *vertex*
|
||||||
|
* property referencing the vertex modified (always a point geometry),
|
||||||
|
* and a *pixel* property referencing the pixel location of the
|
||||||
|
* removal.
|
||||||
* sketchstarted - Triggered when a feature sketch bound for this layer
|
* sketchstarted - Triggered when a feature sketch bound for this layer
|
||||||
* is started. Listeners will receive an object with a *feature*
|
* is started. Listeners will receive an object with a *feature*
|
||||||
* property referencing the new sketch feature and a *vertex* property
|
* property referencing the new sketch feature and a *vertex* property
|
||||||
@@ -110,8 +116,8 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
"beforefeaturesremoved", "featureremoved", "featuresremoved",
|
"beforefeaturesremoved", "featureremoved", "featuresremoved",
|
||||||
"beforefeatureselected", "featureselected", "featureunselected",
|
"beforefeatureselected", "featureselected", "featureunselected",
|
||||||
"beforefeaturemodified", "featuremodified", "afterfeaturemodified",
|
"beforefeaturemodified", "featuremodified", "afterfeaturemodified",
|
||||||
"vertexmodified", "sketchstarted", "sketchmodified",
|
"vertexmodified", "vertexremoved", "sketchstarted",
|
||||||
"sketchcomplete", "refresh"],
|
"sketchmodified", "sketchcomplete", "refresh"],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: isBaseLayer
|
* APIProperty: isBaseLayer
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_handleKeypress(t) {
|
function test_handleKeypress(t) {
|
||||||
t.plan(11);
|
t.plan(14);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are two things that we want to test here
|
* There are two things that we want to test here
|
||||||
@@ -108,9 +108,17 @@
|
|||||||
"vertex deletion: removeComponent called on parent with proper geometry");
|
"vertex deletion: removeComponent called on parent with proper geometry");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
layer.events.on({"featuremodified": function(event) {
|
layer.events.on({
|
||||||
t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
|
"featuremodified": function(event) {
|
||||||
}});
|
t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
|
||||||
|
},
|
||||||
|
"vertexremoved": function(evt) {
|
||||||
|
layer.events.unregister("vertexremoved", this, arguments.callee);
|
||||||
|
t.eq(evt.feature.id, poly.id, "vertexremoved triggered with correct feature");
|
||||||
|
t.eq(evt.vertex.id, point.geometry.id, "vertexremoved triggered with correct vertex");
|
||||||
|
t.eq(evt.pixel, "foo", "vertexremoved triggered with correct pixel");
|
||||||
|
}
|
||||||
|
});
|
||||||
layer.drawFeature = function(feature) {
|
layer.drawFeature = function(feature) {
|
||||||
t.eq(feature.id, poly.id,
|
t.eq(feature.id, poly.id,
|
||||||
"vertex deletion: drawFeature called with the proper feature");
|
"vertex deletion: drawFeature called with the proper feature");
|
||||||
@@ -123,7 +131,7 @@
|
|||||||
"vertex deletion: onModification called with the proper feature");
|
"vertex deletion: onModification called with the proper feature");
|
||||||
};
|
};
|
||||||
// run the above four tests twice
|
// run the above four tests twice
|
||||||
control.handleKeypress({keyCode:delKey});
|
control.handleKeypress({keyCode:delKey, xy: "foo"});
|
||||||
control.handleKeypress({keyCode:dKey});
|
control.handleKeypress({keyCode:dKey});
|
||||||
t.eq(control.feature.state, OpenLayers.State.UPDATE, "feature state set to update");
|
t.eq(control.feature.state, OpenLayers.State.UPDATE, "feature state set to update");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user