From 9b1cf1ef01b43facba84fd08afe25214353139b6 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 13 Mar 2008 04:20:53 +0000 Subject: [PATCH] showPan & showZoomBar options in control PanZoomBar, to turn off the various chunks. In the future, we'll use this to have a single control integrating panzoom and panzoombar, but not quite yet. Revamped patch from kkempfer (thx!) with tests. r=me (Closes #754) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6514 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/PanZoomBar.js | 43 ++++++++++++++++++++-------- tests/Control/test_PanZoomBar.html | 15 +++++++--- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index fca45c9844..6ffeec022b 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -48,6 +48,20 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { * {} */ divEvents: null, + + /** Whether or not Pan icons will be displayed + * Default is true + * + * @type Boolean + */ + showPan: true, + + /** Whether or not ZoomBar will be displayed + * Default is true + * + * @type Boolean + */ + showZoomBar: true, /** * Property: zoomWorldIcon @@ -132,19 +146,24 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { centered = new OpenLayers.Pixel(px.x+sz.w, px.y); } - this._addButton("panup", "north-mini.png", centered, sz); - px.y = centered.y+sz.h; - this._addButton("panleft", "west-mini.png", px, sz); - if (this.zoomWorldIcon) { - this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz); - - wposition *= 2; + if (this.showPan) { + + this._addButton("panup", "north-mini.png", centered, sz); + px.y = centered.y+sz.h; + this._addButton("panleft", "west-mini.png", px, sz); + if (this.zoomWorldIcon) { + this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz); + + wposition *= 2; + } + this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz); + this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); + } + if (this.showZoomBar) { + this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); + centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); + this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); } - this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz); - this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); - this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); - centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); - this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); return this.div; }, diff --git a/tests/Control/test_PanZoomBar.html b/tests/Control/test_PanZoomBar.html index b9c8497879..3286c8bc90 100644 --- a/tests/Control/test_PanZoomBar.html +++ b/tests/Control/test_PanZoomBar.html @@ -4,22 +4,27 @@