~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/lib/OpenLayers/Control/DrawFeature.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. */
 
4
 
 
5
 
 
6
/**
 
7
 * @requires OpenLayers/Control.js
 
8
 * @requires OpenLayers/Feature/Vector.js
 
9
 */
 
10
 
 
11
/**
 
12
 * Class: OpenLayers.Control.DrawFeature
 
13
 * Draws features on a vector layer when active.
 
14
 *
 
15
 * Inherits from:
 
16
 *  - <OpenLayers.Control>
 
17
 */
 
18
OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
 
19
    
 
20
    /**
 
21
     * Property: layer
 
22
     * {<OpenLayers.Layer.Vector>}
 
23
     */
 
24
    layer: null,
 
25
 
 
26
    /**
 
27
     * Property: callbacks
 
28
     * {Object} The functions that are sent to the handler for callback
 
29
     */
 
30
    callbacks: null,
 
31
    
 
32
    /**
 
33
     * Constant: EVENT_TYPES
 
34
     *
 
35
     * Supported event types:
 
36
     *  - *featureadded* Triggered when a feature is added
 
37
     */
 
38
    EVENT_TYPES: ["featureadded"],
 
39
    
 
40
    /**
 
41
     * APIProperty: featureAdded
 
42
     * {Function} Called after each feature is added
 
43
     */
 
44
    featureAdded: function() {},
 
45
 
 
46
    /**
 
47
     * APIProperty: handlerOptions
 
48
     * {Object} Used to set non-default properties on the control's handler
 
49
     */
 
50
    handlerOptions: null,
 
51
    
 
52
    /**
 
53
     * Constructor: OpenLayers.Control.DrawFeature
 
54
     * 
 
55
     * Parameters:
 
56
     * layer - {<OpenLayers.Layer.Vector>} 
 
57
     * handler - {<OpenLayers.Handler>} 
 
58
     * options - {Object} 
 
59
     */
 
60
    initialize: function(layer, handler, options) {
 
61
        
 
62
        // concatenate events specific to vector with those from the base
 
63
        this.EVENT_TYPES =
 
64
            OpenLayers.Control.DrawFeature.prototype.EVENT_TYPES.concat(
 
65
            OpenLayers.Control.prototype.EVENT_TYPES
 
66
        );
 
67
        
 
68
        OpenLayers.Control.prototype.initialize.apply(this, [options]);
 
69
        this.callbacks = OpenLayers.Util.extend({done: this.drawFeature},
 
70
                                                this.callbacks);
 
71
        this.layer = layer;
 
72
        this.handler = new handler(this, this.callbacks, this.handlerOptions);
 
73
    },
 
74
 
 
75
    /**
 
76
     * Method: drawFeature
 
77
     */
 
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});
 
83
    },
 
84
 
 
85
    CLASS_NAME: "OpenLayers.Control.DrawFeature"
 
86
});