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. */
6 * @requires OpenLayers/Control.js
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>.
15 * - <OpenLayers.Control>
17 OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
20 * APIProperty: slideFactor
21 * {Integer} Number of pixels by which we'll pan the map in any direction
22 * on clicking the arrow buttons.
28 * {String} in {'North', 'South', 'East', 'West'}
34 * {String} The type of <OpenLayers.Control> -- When added to a
35 * <Control.Panel>, 'type' is used by the panel to determine how to
38 type: OpenLayers.Control.TYPE_BUTTON,
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.
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.
50 initialize: function(direction, options) {
52 this.direction = direction;
53 this.CLASS_NAME += this.direction;
55 OpenLayers.Control.prototype.initialize.apply(this, [options]);
63 switch (this.direction) {
64 case OpenLayers.Control.Pan.NORTH:
65 this.map.pan(0, -this.slideFactor);
67 case OpenLayers.Control.Pan.SOUTH:
68 this.map.pan(0, this.slideFactor);
70 case OpenLayers.Control.Pan.WEST:
71 this.map.pan(-this.slideFactor, 0);
73 case OpenLayers.Control.Pan.EAST:
74 this.map.pan(this.slideFactor, 0);
79 CLASS_NAME: "OpenLayers.Control.Pan"
82 OpenLayers.Control.Pan.NORTH = "North";
83 OpenLayers.Control.Pan.SOUTH = "South";
84 OpenLayers.Control.Pan.EAST = "East";
85 OpenLayers.Control.Pan.WEST = "West";