This repository has been archived by the owner on Apr 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
DrawPoint.js
59 lines (50 loc) · 1.85 KB
/
DrawPoint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @copyright 2011 geOps
* @license https://github.com/geops/ole/blob/master/license.txt
* @link https://github.com/geops/ole
*/
/**
* Class: OpenLayers.Editor.Control.DrawPoint
*
* Inherits from:
* - <OpenLayers.Control.DrawFeature>
*/
OpenLayers.Editor.Control.DrawPoint = OpenLayers.Class(OpenLayers.Control.DrawFeature, {
title: OpenLayers.i18n('oleDrawPoint'),
featureType: 'point',
/**
* Constructor: OpenLayers.Editor.Control.DrawPath
* Create a new control for drawing points.
*
* Parameters:
* layer - {<OpenLayers.Layer.Vector>} Points will be added to this layer.
* options - {Object} An optional object whose properties will be used
* to extend the control.
*/
initialize: function (layer, options) {
this.callbacks = OpenLayers.Util.extend(this.callbacks, {
point: function (point) {
this.layer.events.triggerEvent('pointadded', {point: point});
}
});
OpenLayers.Control.DrawFeature.prototype.initialize.apply(this,
[layer, OpenLayers.Handler.Point, options]);
this.title = OpenLayers.i18n('oleDrawPoint');
},
/**
* Method: draw point
*/
drawFeature: function (geometry) {
var feature = new OpenLayers.Feature.Vector(geometry),
proceed = this.layer.events.triggerEvent('sketchcomplete', {feature: feature});
feature.featureType = this.featureType;
if (proceed !== false) {
this.events.triggerEvent('beforefeatureadded', {feature: feature});
feature.state = OpenLayers.State.INSERT;
this.layer.addFeatures([feature]);
this.featureAdded(feature);
this.events.triggerEvent('featureadded', {feature: feature});
}
},
CLASS_NAME: 'OpenLayers.Editor.Control.DrawPoint'
});