source:
trunk/workshop-routing-foss4g/web/DrawPoints.js
@
81
Revision 76, 1.0 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 1 | DrawPoints = OpenLayers.Class(OpenLayers.Control.DrawFeature, { |
2 | ||
3 | // this control is active by default | |
4 | autoActivate: true, | |
5 | ||
6 | initialize: function(layer, options) { | |
7 | // only points can be drawn | |
8 | var handler = OpenLayers.Handler.Point; | |
9 | OpenLayers.Control.DrawFeature.prototype.initialize.apply( | |
10 | this, [layer, handler, options] | |
11 | ); | |
12 | }, | |
13 | ||
14 | drawFeature: function(geometry) { | |
15 | OpenLayers.Control.DrawFeature.prototype.drawFeature.apply( | |
16 | this, arguments | |
17 | ); | |
18 | if (this.layer.features.length == 1) { | |
19 | // we just draw the startpoint | |
20 | // note: if we want to apply a special style to the | |
21 | // start point we should do this here | |
22 | } else if (this.layer.features.length == 2) { | |
23 | // we just draw the finalpoint | |
24 | // note: if we want to apply a special style to the | |
25 | // final point we should do this here | |
26 | ||
27 | // we have all what we need; we can deactivate ourself. | |
28 | this.deactivate(); | |
29 | } | |
30 | } | |
31 | }); |
Note: See TracBrowser
for help on using the repository browser.