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