diff --git a/lib/OpenLayers/Control/Pan.js b/lib/OpenLayers/Control/Pan.js index 2850aa83bb..4dfaefea79 100644 --- a/lib/OpenLayers/Control/Pan.js +++ b/lib/OpenLayers/Control/Pan.js @@ -4,7 +4,7 @@ * full text of the license. */ /** - * @requires OpenLayers/Control.js + * @requires OpenLayers/Control/Button.js */ /** @@ -15,7 +15,7 @@ * Inherits from: * - */ -OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, { +OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control.Button, { /** * APIProperty: slideFactor @@ -40,14 +40,6 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, { */ direction: null, - /** - * Property: type - * {String} The type of -- When added to a - * , 'type' is used by the panel to determine how to - * handle our events. - */ - type: OpenLayers.Control.TYPE_BUTTON, - /** * Constructor: OpenLayers.Control.Pan * Control which handles the panning (in any of the cardinal directions) @@ -70,26 +62,27 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, { * Method: trigger */ trigger: function(){ + if (this.map) { + var getSlideFactor = OpenLayers.Function.bind(function (dim) { + return this.slideRatio ? + this.map.getSize()[dim] * this.slideRatio : + this.slideFactor; + }, this); - var getSlideFactor = OpenLayers.Function.bind(function (dim) { - return this.slideRatio ? - this.map.getSize()[dim] * this.slideRatio : - this.slideFactor; - }, this); - - switch (this.direction) { - case OpenLayers.Control.Pan.NORTH: - this.map.pan(0, -getSlideFactor("h")); - break; - case OpenLayers.Control.Pan.SOUTH: - this.map.pan(0, getSlideFactor("h")); - break; - case OpenLayers.Control.Pan.WEST: - this.map.pan(-getSlideFactor("w"), 0); - break; - case OpenLayers.Control.Pan.EAST: - this.map.pan(getSlideFactor("w"), 0); - break; + switch (this.direction) { + case OpenLayers.Control.Pan.NORTH: + this.map.pan(0, -getSlideFactor("h")); + break; + case OpenLayers.Control.Pan.SOUTH: + this.map.pan(0, getSlideFactor("h")); + break; + case OpenLayers.Control.Pan.WEST: + this.map.pan(-getSlideFactor("w"), 0); + break; + case OpenLayers.Control.Pan.EAST: + this.map.pan(getSlideFactor("w"), 0); + break; + } } }, diff --git a/lib/OpenLayers/Control/ZoomIn.js b/lib/OpenLayers/Control/ZoomIn.js index 776172d2d8..afab45004f 100644 --- a/lib/OpenLayers/Control/ZoomIn.js +++ b/lib/OpenLayers/Control/ZoomIn.js @@ -4,7 +4,7 @@ * full text of the license. */ /** - * @requires OpenLayers/Control.js + * @requires OpenLayers/Control/Button.js */ /** @@ -14,21 +14,15 @@ * Inherits from: * - */ -OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control, { +OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control.Button, { - /** - * Property: type - * {String} The type of -- When added to a - * , 'type' is used by the panel to determine how to - * handle our events. - */ - type: OpenLayers.Control.TYPE_BUTTON, - /** * Method: trigger */ trigger: function(){ - this.map.zoomIn(); + if (this.map) { + this.map.zoomIn(); + } }, CLASS_NAME: "OpenLayers.Control.ZoomIn" diff --git a/tests/Control/Pan.html b/tests/Control/Pan.html new file mode 100644 index 0000000000..0c9dfafa44 --- /dev/null +++ b/tests/Control/Pan.html @@ -0,0 +1,201 @@ + + + + + + + +
+ + diff --git a/tests/Control/ZoomIn.html b/tests/Control/ZoomIn.html new file mode 100644 index 0000000000..844ded5bfc --- /dev/null +++ b/tests/Control/ZoomIn.html @@ -0,0 +1,101 @@ + + + + + + + +
+ + diff --git a/tests/Control/ZoomToMaxExtent.html b/tests/Control/ZoomToMaxExtent.html index 674b9842a5..8ed5512b06 100644 --- a/tests/Control/ZoomToMaxExtent.html +++ b/tests/Control/ZoomToMaxExtent.html @@ -25,7 +25,7 @@ function test_ZoomToMaxExtent_constructor (t) { control.destroy(); } -function test_ZoomOut_type(t){ +function test_ZoomToMaxExtent_type (t) { t.plan( 1 ); // setup diff --git a/tests/list-tests.html b/tests/list-tests.html index dbf23429c4..c3deb1701a 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -46,9 +46,11 @@
  • Control/UTFGrid.html
  • Control/WMSGetFeatureInfo.html
  • Control/WMTSGetFeatureInfo.html
  • +
  • Control/Pan.html
  • Control/PanPanel.html
  • Control/SLDSelect.html
  • Control/Zoom.html
  • +
  • Control/ZoomIn.html
  • Control/ZoomOut.html
  • Control/ZoomToMaxExtent.html
  • Events.html