1
|
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
2
|
* full list of contributors). Published under the 2-clause BSD license.
|
3
|
* See license.txt in the OpenLayers distribution or repository for the
|
4
|
* full text of the license. */
|
5
|
|
6
|
/**
|
7
|
* @requires OpenLayers/Control/Panel.js
|
8
|
* @requires OpenLayers/Control/Navigation.js
|
9
|
* @requires OpenLayers/Control/DrawFeature.js
|
10
|
* @requires OpenLayers/Handler/Point.js
|
11
|
* @requires OpenLayers/Handler/Path.js
|
12
|
* @requires OpenLayers/Handler/Polygon.js
|
13
|
*/
|
14
|
|
15
|
/**
|
16
|
* Class: OpenLayers.Control.EditingToolbar
|
17
|
* The EditingToolbar is a panel of 4 controls to draw polygons, lines,
|
18
|
* points, or to navigate the map by panning. By default it appears in the
|
19
|
* upper right corner of the map.
|
20
|
*
|
21
|
* Inherits from:
|
22
|
* - <OpenLayers.Control.Panel>
|
23
|
*/
|
24
|
OpenLayers.Control.EditingToolbar = OpenLayers.Class(
|
25
|
OpenLayers.Control.Panel, {
|
26
|
|
27
|
/**
|
28
|
* APIProperty: citeCompliant
|
29
|
* {Boolean} If set to true, coordinates of features drawn in a map extent
|
30
|
* crossing the date line won't exceed the world bounds. Default is false.
|
31
|
*/
|
32
|
citeCompliant: false,
|
33
|
|
34
|
/**
|
35
|
* Constructor: OpenLayers.Control.EditingToolbar
|
36
|
* Create an editing toolbar for a given layer.
|
37
|
*
|
38
|
* Parameters:
|
39
|
* layer - {<OpenLayers.Layer.Vector>}
|
40
|
* options - {Object}
|
41
|
*/
|
42
|
initialize: function(layer, options) {
|
43
|
OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
|
44
|
|
45
|
this.addControls(
|
46
|
[ new OpenLayers.Control.Navigation() ]
|
47
|
);
|
48
|
var controls = [
|
49
|
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {
|
50
|
displayClass: 'olControlDrawFeaturePoint',
|
51
|
handlerOptions: {citeCompliant: this.citeCompliant}
|
52
|
}),
|
53
|
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {
|
54
|
displayClass: 'olControlDrawFeaturePath',
|
55
|
handlerOptions: {citeCompliant: this.citeCompliant}
|
56
|
}),
|
57
|
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {
|
58
|
displayClass: 'olControlDrawFeaturePolygon',
|
59
|
handlerOptions: {citeCompliant: this.citeCompliant}
|
60
|
})
|
61
|
];
|
62
|
this.addControls(controls);
|
63
|
},
|
64
|
|
65
|
/**
|
66
|
* Method: draw
|
67
|
* calls the default draw, and then activates mouse defaults.
|
68
|
*
|
69
|
* Returns:
|
70
|
* {DOMElement}
|
71
|
*/
|
72
|
draw: function() {
|
73
|
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
|
74
|
if (this.defaultControl === null) {
|
75
|
this.defaultControl = this.controls[0];
|
76
|
}
|
77
|
return div;
|
78
|
},
|
79
|
|
80
|
CLASS_NAME: "OpenLayers.Control.EditingToolbar"
|
81
|
});
|