new slideRatio option for Control.Pan and Control.PanPanel. r=bartvde (closes #3039)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11070 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-02-02 15:00:57 +00:00
parent 5d92c646b6
commit 198b3a9c7f
3 changed files with 79 additions and 15 deletions

View File

@@ -33,10 +33,20 @@ OpenLayers.Control.PanPanel = OpenLayers.Class(OpenLayers.Control.Panel, {
/**
* APIProperty: slideFactor
* {Integer} Number of pixels by which we'll pan the map in any direction
* on clicking the arrow buttons, defaults to 50.
* on clicking the arrow buttons, defaults to 50. 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 Pan Up will
* pan up half the map height.
*/
slideRatio: null,
/**
* Constructor: OpenLayers.Control.PanPanel
* Add the four directional pan buttons.
@@ -47,15 +57,15 @@ OpenLayers.Control.PanPanel = OpenLayers.Class(OpenLayers.Control.Panel, {
*/
initialize: function(options) {
OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
var options = {
slideFactor: this.slideFactor,
slideRatio: this.slideRatio
};
this.addControls([
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH,
{slideFactor: this.slideFactor}),
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH,
{slideFactor: this.slideFactor}),
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST,
{slideFactor: this.slideFactor}),
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST,
{slideFactor: this.slideFactor})
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH, options),
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH, options),
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST, options),
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST, options)
]);
},