Changeset 6514
- Timestamp:
- 03/13/08 00:20:53 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js
r6331 r6514 49 49 */ 50 50 divEvents: null, 51 52 /** Whether or not Pan icons will be displayed 53 * Default is true 54 * 55 * @type Boolean 56 */ 57 showPan: true, 58 59 /** Whether or not ZoomBar will be displayed 60 * Default is true 61 * 62 * @type Boolean 63 */ 64 showZoomBar: true, 51 65 52 66 /** … … 133 147 } 134 148 135 this._addButton("panup", "north-mini.png", centered, sz); 136 px.y = centered.y+sz.h; 137 this._addButton("panleft", "west-mini.png", px, sz); 138 if (this.zoomWorldIcon) { 139 this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz); 140 141 wposition *= 2; 142 } 143 this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz); 144 this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); 145 this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); 146 centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); 147 this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); 149 if (this.showPan) { 150 151 this._addButton("panup", "north-mini.png", centered, sz); 152 px.y = centered.y+sz.h; 153 this._addButton("panleft", "west-mini.png", px, sz); 154 if (this.zoomWorldIcon) { 155 this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz); 156 157 wposition *= 2; 158 } 159 this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz); 160 this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); 161 } 162 if (this.showZoomBar) { 163 this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); 164 centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); 165 this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); 166 } 148 167 return this.div; 149 168 }, trunk/openlayers/tests/Control/test_PanZoomBar.html
r4059 r6514 5 5 var map; 6 6 function test_01_Control_PanZoomBar_constructor (t) { 7 t.plan( 4 ); 7 8 t.plan( 6 ); 9 8 10 9 control = new OpenLayers.Control.PanZoomBar({position: new OpenLayers.Pixel(100,100) });11 control = new OpenLayers.Control.PanZoomBar({position: new OpenLayers.Pixel(100,100), showPan: false, showZoomBar: false}); 10 12 t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" ); 11 13 t.eq( control.displayClass, "olControlPanZoomBar", "displayClass is correct" ); 12 14 t.eq( control.position.x, 100, "PanZoom X Set correctly."); 13 15 t.eq( control.position.y, 100, "PanZoom y Set correctly."); 16 t.eq( control.showPan, false, "showPan Set correctly."); 17 t.eq( control.showZoomBar, false, "showZoomBar Set correctly."); 18 14 19 } 15 20 function test_02_Control_PanZoomBar_addControl (t) { 16 t.plan( 8);21 t.plan( 10 ); 17 22 map = new OpenLayers.Map('map', {controls:[]}); 18 23 var layer = new OpenLayers.Layer.WMS("Test Layer", … … 20 25 {map: "/mapdata/vmap_wms.map", layers: "basic"}); 21 26 map.addLayer(layer); 22 control = new OpenLayers.Control.PanZoomBar( );27 control = new OpenLayers.Control.PanZoomBar({showPan: false, showZoomBar: false}); 23 28 t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" ); 24 29 t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" ); … … 29 34 t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), 1001, "Viewport div contains control div" ); 30 35 t.eq( control.div.style.top, "4px", "Control div top located correctly by default"); 36 t.eq( control.div.childNodes.length, 0, "showPan/showZoomBar work correctly"); 31 37 32 38 var control2 = new OpenLayers.Control.PanZoomBar(); 33 39 map.addControl(control2, new OpenLayers.Pixel(100,100)); 34 40 t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); 41 t.eq( control2.div.childNodes.length, 8, "showPan/showZoomBar work correctly on 2nd control div"); 35 42 } 36 43
