~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to static/scripts/gis/openlayers/lib/OpenLayers/Control/EditingToolbar.js

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

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
 * @requires OpenLayers/Control/Panel.js
 
7
 * @requires OpenLayers/Control/Navigation.js
 
8
 * @requires OpenLayers/Control/DrawFeature.js
 
9
 * @requires OpenLayers/Handler/Point.js
 
10
 * @requires OpenLayers/Handler/Path.js
 
11
 * @requires OpenLayers/Handler/Polygon.js
 
12
 */
 
13
 
 
14
/**
 
15
 * Class: OpenLayers.Control.EditingToolbar 
 
16
 * The EditingToolbar is a panel of 4 controls to draw polygons, lines, 
 
17
 * points, or to navigate the map by panning. By default it appears in the 
 
18
 * upper right corner of the map.
 
19
 * 
 
20
 * Inherits from:
 
21
 *  - <OpenLayers.Control.Panel>
 
22
 */
 
23
OpenLayers.Control.EditingToolbar = OpenLayers.Class(
 
24
  OpenLayers.Control.Panel, {
 
25
 
 
26
    /**
 
27
     * Constructor: OpenLayers.Control.EditingToolbar
 
28
     * Create an editing toolbar for a given layer. 
 
29
     *
 
30
     * Parameters:
 
31
     * layer - {<OpenLayers.Layer.Vector>} 
 
32
     * options - {Object} 
 
33
     */
 
34
    initialize: function(layer, options) {
 
35
        OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
 
36
        
 
37
        this.addControls(
 
38
          [ new OpenLayers.Control.Navigation() ]
 
39
        );  
 
40
        var controls = [
 
41
          new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {'displayClass': 'olControlDrawFeaturePoint'}),
 
42
          new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'}),
 
43
          new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {'displayClass': 'olControlDrawFeaturePolygon'})
 
44
        ];
 
45
        this.addControls(controls);
 
46
    },
 
47
 
 
48
    /**
 
49
     * Method: draw
 
50
     * calls the default draw, and then activates mouse defaults.
 
51
     *
 
52
     * Returns:
 
53
     * {DOMElement}
 
54
     */
 
55
    draw: function() {
 
56
        var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
 
57
        this.activateControl(this.controls[0]);
 
58
        return div;
 
59
    },
 
60
 
 
61
    CLASS_NAME: "OpenLayers.Control.EditingToolbar"
 
62
});