1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3
* full text of the license. */
7
* @requires OpenLayers/Control.js
8
* @requires OpenLayers/Feature/Vector.js
12
* Class: OpenLayers.Control.DrawFeature
13
* Draws features on a vector layer when active.
16
* - <OpenLayers.Control>
18
OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
22
* {<OpenLayers.Layer.Vector>}
28
* {Object} The functions that are sent to the handler for callback
33
* Constant: EVENT_TYPES
35
* Supported event types:
36
* - *featureadded* Triggered when a feature is added
38
EVENT_TYPES: ["featureadded"],
41
* APIProperty: featureAdded
42
* {Function} Called after each feature is added
44
featureAdded: function() {},
47
* APIProperty: handlerOptions
48
* {Object} Used to set non-default properties on the control's handler
53
* Constructor: OpenLayers.Control.DrawFeature
56
* layer - {<OpenLayers.Layer.Vector>}
57
* handler - {<OpenLayers.Handler>}
60
initialize: function(layer, handler, options) {
62
// concatenate events specific to vector with those from the base
64
OpenLayers.Control.DrawFeature.prototype.EVENT_TYPES.concat(
65
OpenLayers.Control.prototype.EVENT_TYPES
68
OpenLayers.Control.prototype.initialize.apply(this, [options]);
69
this.callbacks = OpenLayers.Util.extend({done: this.drawFeature},
72
this.handler = new handler(this, this.callbacks, this.handlerOptions);
78
drawFeature: function(geometry) {
79
var feature = new OpenLayers.Feature.Vector(geometry);
80
this.layer.addFeatures([feature]);
81
this.featureAdded(feature);
82
this.events.triggerEvent("featureadded",{feature : feature});
85
CLASS_NAME: "OpenLayers.Control.DrawFeature"