Merge vector-2.4 branch back to trunk.
svn merge sandbox/vector-2.4/@2307 sandbox/vector-2.4/@HEAD trunk/openlayers/ git-svn-id: http://svn.openlayers.org/trunk/openlayers@2803 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
63
lib/OpenLayers/Control/DrawFeature.js
Normal file
63
lib/OpenLayers/Control/DrawFeature.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/* 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. */
|
||||
|
||||
|
||||
/**
|
||||
* Draws features on a vector layer when active.
|
||||
*
|
||||
* @class
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Feature/Vector.js
|
||||
*/
|
||||
OpenLayers.Control.DrawFeature = OpenLayers.Class.create();
|
||||
OpenLayers.Control.DrawFeature.prototype =
|
||||
OpenLayers.Class.inherit(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* @type OpenLayers.Layer.Vector
|
||||
*/
|
||||
layer: null,
|
||||
|
||||
/**
|
||||
* @type {Object} The functions that are sent to the handler for callback
|
||||
*/
|
||||
callbacks: {},
|
||||
|
||||
/**
|
||||
* @type {Function} Called after each feature is added
|
||||
*/
|
||||
featureAdded: function() {},
|
||||
|
||||
/**
|
||||
* Used to set non-default properties on the control's handler
|
||||
*
|
||||
* @type Object
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Layer.Vector} layer
|
||||
* @param {OpenLayers.Handler} handler
|
||||
* @param {Object} options
|
||||
*/
|
||||
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);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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"
|
||||
});
|
||||
Reference in New Issue
Block a user