[OpenLayers-Commits] r11746 - in trunk/openlayers:
lib/OpenLayers/Control tests/Control
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Tue Mar 29 08:05:28 EDT 2011
Author: sbrunner
Date: 2011-03-29 05:05:26 -0700 (Tue, 29 Mar 2011)
New Revision: 11746
Modified:
trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js
trunk/openlayers/tests/Control/PanZoomBar.html
Log:
fix Allow to have PanZoomBar without pan icons, r=erilem (closes #3167)
Modified: trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js 2011-03-29 12:00:58 UTC (rev 11745)
+++ trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js 2011-03-29 12:05:26 UTC (rev 11746)
@@ -60,6 +60,14 @@
zoomWorldIcon: false,
/**
+ * APIProperty: panIcons
+ * {Boolean} Set this property to false not to display the pan icons. If
+ * false the zoom world icon is placed under the zoom bar. Defaults to
+ * true.
+ */
+ panIcons: true,
+
+ /**
* APIProperty: forceFixedZoomLevel
* {Boolean} Force a fixed zoom level even though the map has
* fractionalZoom
@@ -144,26 +152,37 @@
this.buttons = [];
var sz = new OpenLayers.Size(18,18);
- var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
- var wposition = sz.w;
+ if (this.panIcons) {
+ var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
+ var wposition = sz.w;
- if (this.zoomWorldIcon) {
- centered = new OpenLayers.Pixel(px.x+sz.w, px.y);
- }
+ if (this.zoomWorldIcon) {
+ 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;
+ 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);
+ 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);
+ else {
+ this._addButton("zoomin", "zoom-plus-mini.png", px, sz);
+ centered = this._addZoomBar(px.add(0, sz.h));
+ this._addButton("zoomout", "zoom-minus-mini.png", centered, sz);
+ if (this.zoomWorldIcon) {
+ centered = centered.add(0, sz.h+3);
+ this._addButton("zoomworld", "zoom-world-mini.png", centered, sz);
+ }
+ }
return this.div;
},
Modified: trunk/openlayers/tests/Control/PanZoomBar.html
===================================================================
--- trunk/openlayers/tests/Control/PanZoomBar.html 2011-03-29 12:00:58 UTC (rev 11745)
+++ trunk/openlayers/tests/Control/PanZoomBar.html 2011-03-29 12:05:26 UTC (rev 11746)
@@ -166,6 +166,50 @@
t.ok(map.zoom >= 0, 'map.zoom is never < 0 after random handle drag with forceFixedZoomLevel=true and fractionalZoom=true');
}
}
+
+ function test_Control_PanZoomBar_shows (t) {
+ t.plan(22);
+
+ var control, map;
+
+ control = new OpenLayers.Control.PanZoomBar({panIcons: true, zoomWorldIcon: false});
+ map = new OpenLayers.Map('map', {controls: [control]});
+ t.eq(control.buttons.length, 6, "(a) pan, no world - expected number of buttons");
+ t.ok(control.buttons[0].id.match("_panup$"), "(a) pan, no world - pan up");
+ t.ok(control.buttons[1].id.match("_panleft$"), "(a) pan, no world - pan left");
+ t.ok(control.buttons[2].id.match("_panright$"), "(a) pan, no world - pan right");
+ t.ok(control.buttons[3].id.match("_pandown$"), "(a) pan, no world - pan down");
+ t.ok(control.buttons[4].id.match("_zoomin$"), "(a) pan, no world - zoom in");
+ t.ok(control.buttons[5].id.match("_zoomout$"), "(a) pan, no world - zoom out");
+ map.destroy();
+
+ control = new OpenLayers.Control.PanZoomBar({panIcons: true, zoomWorldIcon: true});
+ map = new OpenLayers.Map('map', {controls:[control]});
+ t.eq(control.buttons.length, 7, "(b) pan, world - expected number of buttons");
+ t.ok(control.buttons[0].id.match("_panup$"), "(b) pan, world - pan up");
+ t.ok(control.buttons[1].id.match("_panleft$"), "(b) pan, world - pan left");
+ t.ok(control.buttons[2].id.match("_zoomworld$"), "(b) pan, world - zoom world");
+ t.ok(control.buttons[3].id.match("_panright$"), "(b) pan, world - pan right");
+ t.ok(control.buttons[4].id.match("_pandown$"), "(b) pan, world - pan down");
+ t.ok(control.buttons[5].id.match("_zoomin$"), "(b) pan, world - zoom in");
+ t.ok(control.buttons[6].id.match("_zoomout$"), "(b) pan, world - zoom out");
+ map.destroy();
+
+ control = new OpenLayers.Control.PanZoomBar({panIcons: false, zoomWorldIcon: false});
+ map = new OpenLayers.Map('map', {controls:[control]});
+ t.eq(control.buttons.length, 2, "(c) no pan, no world - expected number of buttons");
+ t.ok(control.buttons[0].id.match("_zoomin$"), "(c) no pan, no world - zoom in");
+ t.ok(control.buttons[1].id.match("_zoomout$"), "(c) no pan, no world - zoom out");
+ map.destroy();
+
+ control = new OpenLayers.Control.PanZoomBar({panIcons: false, zoomWorldIcon: true});
+ map = new OpenLayers.Map('map', {controls:[control]});
+ t.eq(control.buttons.length, 3, "(d) no pan, world - expected number of buttons");
+ t.ok(control.buttons[0].id.match("_zoomin$"), "(d) no pan, world - zoom in");
+ t.ok(control.buttons[1].id.match("_zoomout$"), "(d) no pan, world - zoom out");
+ t.ok(control.buttons[2].id.match("_zoomworld$"), "(d) no pan, world - zoom world");
+ map.destroy();
+ }
</script>
</head>
<body>
More information about the Commits
mailing list