Adding a slideRatio property to the PanZoom control. Setting this will cause the pan buttons to pan the map by a ratio of the map dimensions. A slideRatio of 0.5 will cause pan up to pan by half the map height. Thanks for the patch and tests sbenthall. r=me (closes #1998)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9129 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -21,10 +21,20 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
/**
|
||||
* APIProperty: slideFactor
|
||||
* {Integer} Number of pixels by which we'll pan the map in any direction
|
||||
* on clicking the arrow buttons.
|
||||
* on clicking the arrow buttons. If you want to pan by some ratio
|
||||
* of the map dimensions, use <slideRatio> instead.
|
||||
*/
|
||||
slideFactor: 50,
|
||||
|
||||
/**
|
||||
* APIProperty: slideRatio
|
||||
* {Number} The fraction of map width/height by which we'll pan the map
|
||||
* on clicking the arrow buttons. Default is null. If set, will
|
||||
* override <slideFactor>. E.g. if slideRatio is .5, then the Pan Up
|
||||
* button will pan up half the map height.
|
||||
*/
|
||||
slideRatio: null,
|
||||
|
||||
/**
|
||||
* Property: buttons
|
||||
* {Array(DOMElement)} Array of Button Divs
|
||||
@@ -124,7 +134,20 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Function.bindAsEventListener(this.doubleClick, btn));
|
||||
btn.action = id;
|
||||
btn.map = this.map;
|
||||
btn.slideFactor = this.slideFactor;
|
||||
|
||||
if(!this.slideRatio){
|
||||
var slideFactorPixels = this.slideFactor;
|
||||
var getSlideFactor = function() {
|
||||
return slideFactorPixels;
|
||||
};
|
||||
} else {
|
||||
var slideRatio = this.slideRatio;
|
||||
var getSlideFactor = function(dim) {
|
||||
return this.map.getSize()[dim] * slideRatio;
|
||||
};
|
||||
}
|
||||
|
||||
btn.getSlideFactor = getSlideFactor;
|
||||
|
||||
//we want to remember/reference the outer div
|
||||
this.buttons.push(btn);
|
||||
@@ -180,16 +203,16 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
switch (this.action) {
|
||||
case "panup":
|
||||
this.map.pan(0, -this.slideFactor);
|
||||
this.map.pan(0, -this.getSlideFactor("h"));
|
||||
break;
|
||||
case "pandown":
|
||||
this.map.pan(0, this.slideFactor);
|
||||
this.map.pan(0, this.getSlideFactor("h"));
|
||||
break;
|
||||
case "panleft":
|
||||
this.map.pan(-this.slideFactor, 0);
|
||||
this.map.pan(-this.getSlideFactor("w"), 0);
|
||||
break;
|
||||
case "panright":
|
||||
this.map.pan(this.slideFactor, 0);
|
||||
this.map.pan(this.getSlideFactor("w"), 0);
|
||||
break;
|
||||
case "zoomin":
|
||||
this.map.zoomIn();
|
||||
|
||||
Reference in New Issue
Block a user