has been done in the NaturalDocs branch back to trunk. Thanks to everyone who helped out in making this happen. (I could list people, but the list would be long, and I'm already mentally on vacation.) git-svn-id: http://svn.openlayers.org/trunk/openlayers@3545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
|
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
|
* for the full text of the license. */
|
|
|
|
|
|
/**
|
|
* @requires OpenLayers/Control.js
|
|
* @requires OpenLayers/Feature/Vector.js
|
|
*
|
|
* Class: OpenLayers.Control.DrawFeature
|
|
* Draws features on a vector layer when active.
|
|
*
|
|
* Inherits from:
|
|
* - <OpenLayers.Control>
|
|
*/
|
|
OpenLayers.Control.DrawFeature = OpenLayers.Class.create();
|
|
OpenLayers.Control.DrawFeature.prototype =
|
|
OpenLayers.Class.inherit(OpenLayers.Control, {
|
|
|
|
/**
|
|
* Property: layer
|
|
* {<OpenLayers.Layer.Vector>}
|
|
*/
|
|
layer: null,
|
|
|
|
/**
|
|
* Property: callbacks
|
|
* {Object} The functions that are sent to the handler for callback
|
|
*/
|
|
callbacks: null,
|
|
|
|
/**
|
|
* APIProperty: featureAdded
|
|
* {Function} Called after each feature is added
|
|
*/
|
|
featureAdded: function() {},
|
|
|
|
/**
|
|
* APIProperty: handlerOptions
|
|
* {Object} Used to set non-default properties on the control's handler
|
|
*/
|
|
handlerOptions: null,
|
|
|
|
/**
|
|
* Constructor: OpenLayers.Control.DrawFeature
|
|
*
|
|
* Parameters:
|
|
* layer - {<OpenLayers.Layer.Vector>}
|
|
* handler - {<OpenLayers.Handler>}
|
|
* options - {Object}
|
|
*/
|
|
initialize: function(layer, handler, options) {
|
|
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
|
this.callbacks = OpenLayers.Util.extend({done: this.drawFeature},
|
|
this.callbacks);
|
|
this.layer = layer;
|
|
this.handler = new handler(this, this.callbacks, this.handlerOptions);
|
|
},
|
|
|
|
/**
|
|
* Method: drawFeature
|
|
*/
|
|
drawFeature: function(geometry) {
|
|
var feature = new OpenLayers.Feature.Vector(geometry);
|
|
this.layer.addFeatures([feature]);
|
|
this.featureAdded(feature);
|
|
},
|
|
|
|
/** @final @type String */
|
|
CLASS_NAME: "OpenLayers.Control.DrawFeature"
|
|
});
|