Protect the trigger action of pan control by checking whether

we were added to a map prior to calling this.map.pan().
This commit is contained in:
Marc Jansen
2012-04-17 21:25:56 +02:00
parent 53ed973eec
commit 56d7cee8cf

View File

@@ -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;
}
}
},