source:
trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Control/DragPan.js
@
76
Revision 76, 2.4 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
2 | * full list of contributors). Published under the Clear BSD license. | |
3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the | |
4 | * full text of the license. */ | |
5 | ||
6 | /** | |
7 | * @requires OpenLayers/Control.js | |
8 | * @requires OpenLayers/Handler/Drag.js | |
9 | */ | |
10 | ||
11 | /** | |
12 | * Class: OpenLayers.Control.DragPan | |
13 | * The DragPan control pans the map with a drag of the mouse. | |
14 | * | |
15 | * Inherits from: | |
16 | * - <OpenLayers.Control> | |
17 | */ | |
18 | OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, { | |
19 | ||
20 | /** | |
21 | * Property: type | |
22 | * {OpenLayers.Control.TYPES} | |
23 | */ | |
24 | type: OpenLayers.Control.TYPE_TOOL, | |
25 | ||
26 | /** | |
27 | * Property: panned | |
28 | * {Boolean} The map moved. | |
29 | */ | |
30 | panned: false, | |
31 | ||
32 | /** | |
33 | * Property: interval | |
34 | * {Integer} The number of milliseconds that should ellapse before | |
35 | * panning the map again. Set this to increase dragging performance. | |
36 | * Defaults to 25 milliseconds. | |
37 | */ | |
38 | interval: 25, | |
39 | ||
40 | /** | |
41 | * APIProperty: documentDrag | |
42 | * {Boolean} If set to true, mouse dragging will continue even if the | |
43 | * mouse cursor leaves the map viewport. Default is false. | |
44 | */ | |
45 | documentDrag: false, | |
46 | ||
47 | /** | |
48 | * Method: draw | |
49 | * Creates a Drag handler, using <panMap> and | |
50 | * <panMapDone> as callbacks. | |
51 | */ | |
52 | draw: function() { | |
53 | this.handler = new OpenLayers.Handler.Drag(this, { | |
54 | "move": this.panMap, | |
55 | "done": this.panMapDone | |
56 | }, { | |
57 | interval: this.interval, | |
58 | documentDrag: this.documentDrag | |
59 | } | |
60 | ); | |
61 | }, | |
62 | ||
63 | /** | |
64 | * Method: panMap | |
65 | * | |
66 | * Parameters: | |
67 | * xy - {<OpenLayers.Pixel>} Pixel of the mouse position | |
68 | */ | |
69 | panMap: function(xy) { | |
70 | this.panned = true; | |
71 | this.map.pan( | |
72 | this.handler.last.x - xy.x, | |
73 | this.handler.last.y - xy.y, | |
74 | {dragging: this.handler.dragging, animate: false} | |
75 | ); | |
76 | }, | |
77 | ||
78 | /** | |
79 | * Method: panMapDone | |
80 | * Finish the panning operation. Only call setCenter (through <panMap>) | |
81 | * if the map has actually been moved. | |
82 | * | |
83 | * Parameters: | |
84 | * xy - {<OpenLayers.Pixel>} Pixel of the mouse position | |
85 | */ | |
86 | panMapDone: function(xy) { | |
87 | if(this.panned) { | |
88 | this.panMap(xy); | |
89 | this.panned = false; | |
90 | } | |
91 | }, | |
92 | ||
93 | CLASS_NAME: "OpenLayers.Control.DragPan" | |
94 | }); |
Note: See TracBrowser
for help on using the repository browser.