diff --git a/lib/OpenLayers/Control/DrawFeature.js b/lib/OpenLayers/Control/DrawFeature.js index dcb341233e..00bf5f94ad 100644 --- a/lib/OpenLayers/Control/DrawFeature.js +++ b/lib/OpenLayers/Control/DrawFeature.js @@ -29,6 +29,14 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, { */ callbacks: null, + /** + * Constant: EVENT_TYPES + * + * Supported event types: + * - *featureadded* Triggered when a feature is added + */ + EVENT_TYPES: ["featureadded"], + /** * APIProperty: featureAdded * {Function} Called after each feature is added @@ -50,6 +58,13 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, { * options - {Object} */ initialize: function(layer, handler, options) { + + // concatenate events specific to vector with those from the base + this.EVENT_TYPES = + OpenLayers.Control.DrawFeature.prototype.EVENT_TYPES.concat( + OpenLayers.Control.prototype.EVENT_TYPES + ); + OpenLayers.Control.prototype.initialize.apply(this, [options]); this.callbacks = OpenLayers.Util.extend({done: this.drawFeature}, this.callbacks); @@ -64,6 +79,7 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, { var feature = new OpenLayers.Feature.Vector(geometry); this.layer.addFeatures([feature]); this.featureAdded(feature); + this.events.triggerEvent("featureadded",{feature : feature}); }, CLASS_NAME: "OpenLayers.Control.DrawFeature" diff --git a/tests/Control/DrawFeature.html b/tests/Control/DrawFeature.html new file mode 100644 index 0000000000..c723625ce2 --- /dev/null +++ b/tests/Control/DrawFeature.html @@ -0,0 +1,38 @@ + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index a4db211c54..899b35924a 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -90,6 +90,7 @@
  • Control/Button.html
  • Control/DragFeature.html
  • Control/DragPan.html
  • +
  • Control/DrawFeature.html
  • Control/LayerSwitcher.html
  • Control/ModifyFeature.html
  • Control/MousePosition.html