PanPanel.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (c) 2006-2011 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. * @requires OpenLayers/Control/Panel.js
  7. * @requires OpenLayers/Control/Pan.js
  8. */
  9. /**
  10. * Class: OpenLayers.Control.PanPanel
  11. * The PanPanel is visible control for panning the map North, South, East or
  12. * West in small steps. By default it is drawn in the top left corner of the
  13. * map.
  14. *
  15. * Note:
  16. * If you wish to use this class with the default images and you want
  17. * it to look nice in ie6, you should add the following, conditionally
  18. * added css stylesheet to your HTML file:
  19. *
  20. * (code)
  21. * <!--[if lte IE 6]>
  22. * <link rel="stylesheet" href="../theme/default/ie6-style.css" type="text/css" />
  23. * <![endif]-->
  24. * (end)
  25. *
  26. * Inherits from:
  27. * - <OpenLayers.Control.Panel>
  28. */
  29. OpenLayers.Control.PanPanel = OpenLayers.Class(OpenLayers.Control.Panel, {
  30. /**
  31. * APIProperty: slideFactor
  32. * {Integer} Number of pixels by which we'll pan the map in any direction
  33. * on clicking the arrow buttons, defaults to 50. If you want to pan
  34. * by some ratio of the map dimensions, use <slideRatio> instead.
  35. */
  36. slideFactor: 50,
  37. /**
  38. * APIProperty: slideRatio
  39. * {Number} The fraction of map width/height by which we'll pan the map
  40. * on clicking the arrow buttons. Default is null. If set, will
  41. * override <slideFactor>. E.g. if slideRatio is .5, then Pan Up will
  42. * pan up half the map height.
  43. */
  44. slideRatio: null,
  45. /**
  46. * Constructor: OpenLayers.Control.PanPanel
  47. * Add the four directional pan buttons.
  48. *
  49. * Parameters:
  50. * options - {Object} An optional object whose properties will be used
  51. * to extend the control.
  52. */
  53. initialize: function(options) {
  54. OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
  55. var options = {
  56. slideFactor: this.slideFactor,
  57. slideRatio: this.slideRatio
  58. };
  59. this.addControls([
  60. new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH, options),
  61. new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH, options),
  62. new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST, options),
  63. new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST, options)
  64. ]);
  65. },
  66. CLASS_NAME: "OpenLayers.Control.PanPanel"
  67. });