Ticket #754: panzoombar.2.patch
| File panzoombar.2.patch, 4.5 kB (added by kkempfer, 1 year ago) |
|---|
-
tests/Control/test_PanZoomBar.html
old new 4 4 <script type="text/javascript"> 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", 19 24 "http://octo.metacarta.com/cgi-bin/mapserv?", 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" ); 25 30 map.addControl(control); … … 28 33 t.eq( parseInt(control.div.style.zIndex), 1001, "Control div zIndexed properly" ); 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 37 44 </script> -
lib/OpenLayers/Control/PanZoomBar.js
old new 46 46 * {<OpenLayers.Events>} 47 47 */ 48 48 divEvents: null, 49 50 /** Whether or not Pan icons will be displayed 51 * Default is true 52 * 53 * @type Boolean 54 */ 55 showPan: true, 56 57 /** Whether or not ZoomBar will be displayed 58 * Default is true 59 * 60 * @type Boolean 61 */ 62 showZoomBar: true, 49 63 50 64 /** 51 65 * Constructor: <OpenLayers.Control.PanZoomBar> … … 115 129 116 130 var sz = new OpenLayers.Size(18,18); 117 131 var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); 118 119 this._addButton("panup", "north-mini.png", centered, sz); 120 px.y = centered.y+sz.h; 121 this._addButton("panleft", "west-mini.png", px, sz); 122 this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz); 123 this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); 124 this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); 125 centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); 126 this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); 132 if(this.showPan){ 133 this._addButton("panup", "north-mini.png", centered, sz); 134 px.y = centered.y+sz.h; 135 this._addButton("panleft", "west-mini.png", px, sz); 136 this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz); 137 this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); 138 } 139 if(this.showZoomBar){ 140 this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); 141 centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); 142 this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); 143 } 127 144 return this.div; 128 145 }, 129 146
