~hwfwill/sahana-eden/test

« back to all changes in this revision

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

  • Committer: William
  • Date: 2010-08-01 10:21:30 UTC
  • Revision ID: william@william-tp-20100801102130-cuw199enh3ot2vbg
changed

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.js
 
7
 */
 
8
 
 
9
/**
 
10
 * Class: OpenLayers.Control.Pan
 
11
 * The Pan control is a single button to pan the map in one direction. For
 
12
 * a more complete control see <OpenLayers.Control.PanPanel>.
 
13
 *
 
14
 * Inherits from:
 
15
 *  - <OpenLayers.Control>
 
16
 */
 
17
OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
 
18
 
 
19
    /** 
 
20
     * APIProperty: slideFactor
 
21
     * {Integer} Number of pixels by which we'll pan the map in any direction 
 
22
     *     on clicking the arrow buttons, defaults to 50.
 
23
     */
 
24
    slideFactor: 50,
 
25
 
 
26
    /** 
 
27
     * Property: direction
 
28
     * {String} in {'North', 'South', 'East', 'West'}
 
29
     */
 
30
    direction: null,
 
31
 
 
32
    /**
 
33
     * Property: type
 
34
     * {String} The type of <OpenLayers.Control> -- When added to a 
 
35
     *     <Control.Panel>, 'type' is used by the panel to determine how to 
 
36
     *     handle our events.
 
37
     */
 
38
    type: OpenLayers.Control.TYPE_BUTTON,
 
39
 
 
40
    /**
 
41
     * Constructor: OpenLayers.Control.Pan 
 
42
     * Control which handles the panning (in any of the cardinal directions)
 
43
     *     of the map by a set px distance. 
 
44
     *
 
45
     * Parameters:
 
46
     * direction - {String} The direction this button should pan.
 
47
     * options - {Object} An optional object whose properties will be used
 
48
     *     to extend the control.
 
49
     */
 
50
    initialize: function(direction, options) {
 
51
    
 
52
        this.direction = direction;
 
53
        this.CLASS_NAME += this.direction;
 
54
        
 
55
        OpenLayers.Control.prototype.initialize.apply(this, [options]);
 
56
    },
 
57
    
 
58
    /**
 
59
     * Method: trigger
 
60
     */
 
61
    trigger: function(){
 
62
    
 
63
        switch (this.direction) {
 
64
            case OpenLayers.Control.Pan.NORTH: 
 
65
                this.map.pan(0, -this.slideFactor);
 
66
                break;
 
67
            case OpenLayers.Control.Pan.SOUTH: 
 
68
                this.map.pan(0, this.slideFactor);
 
69
                break;
 
70
            case OpenLayers.Control.Pan.WEST: 
 
71
                this.map.pan(-this.slideFactor, 0);
 
72
                break;
 
73
            case OpenLayers.Control.Pan.EAST: 
 
74
                this.map.pan(this.slideFactor, 0);
 
75
                break;
 
76
        }
 
77
    },
 
78
 
 
79
    CLASS_NAME: "OpenLayers.Control.Pan"
 
80
});
 
81
 
 
82
OpenLayers.Control.Pan.NORTH = "North";
 
83
OpenLayers.Control.Pan.SOUTH = "South";
 
84
OpenLayers.Control.Pan.EAST = "East";
 
85
OpenLayers.Control.Pan.WEST = "West";