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:
@@ -70,26 +70,27 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
* Method: trigger
|
* Method: trigger
|
||||||
*/
|
*/
|
||||||
trigger: function(){
|
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) {
|
switch (this.direction) {
|
||||||
return this.slideRatio ?
|
case OpenLayers.Control.Pan.NORTH:
|
||||||
this.map.getSize()[dim] * this.slideRatio :
|
this.map.pan(0, -getSlideFactor("h"));
|
||||||
this.slideFactor;
|
break;
|
||||||
}, this);
|
case OpenLayers.Control.Pan.SOUTH:
|
||||||
|
this.map.pan(0, getSlideFactor("h"));
|
||||||
switch (this.direction) {
|
break;
|
||||||
case OpenLayers.Control.Pan.NORTH:
|
case OpenLayers.Control.Pan.WEST:
|
||||||
this.map.pan(0, -getSlideFactor("h"));
|
this.map.pan(-getSlideFactor("w"), 0);
|
||||||
break;
|
break;
|
||||||
case OpenLayers.Control.Pan.SOUTH:
|
case OpenLayers.Control.Pan.EAST:
|
||||||
this.map.pan(0, getSlideFactor("h"));
|
this.map.pan(getSlideFactor("w"), 0);
|
||||||
break;
|
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;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user