diff --git a/lib/OpenLayers/Control/Pan.js b/lib/OpenLayers/Control/Pan.js index 2850aa83bb..2c85caa10f 100644 --- a/lib/OpenLayers/Control/Pan.js +++ b/lib/OpenLayers/Control/Pan.js @@ -70,26 +70,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; + } } },