OpenLayers OpenLayers

Ticket #754: panzoombar.patch

File panzoombar.patch, 3.1 kB (added by kkempfer, 1 year ago)
  • tests/Control/test_PanZoomBar.html

    old new  
    44  <script type="text/javascript"><!-- 
    55    var map;  
    66    function test_01_Control_PanZoomBar_constructor (t) { 
    7         t.plan( 3 ); 
     7        t.plan( 5 ); 
    88     
    9         control = new OpenLayers.Control.PanZoomBar({position: new OpenLayers.Pixel(100,100)}); 
     9        control = new OpenLayers.Control.PanZoomBar({position: new OpenLayers.Pixel(100,100), showPan: false, showZoomBar: false}); 
    1010        t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" ); 
    1111        t.eq( control.position.x, 100, "PanZoom X Set correctly.");  
    1212        t.eq( control.position.y, 100, "PanZoom y Set correctly.");  
     13        t.eq( control.showPan, false, "showPan Set correctly.");  
     14        t.eq( control.showZoomBar, false, "showZoomBar Set correctly.");  
    1315    } 
    1416    function test_02_Control_PanZoomBar_addControl (t) { 
    1517        t.plan( 8 ); 
  • lib/OpenLayers/Control/PanZoomBar.js

    old new  
    2929 
    3030    /** @type OpenLayers.Events */ 
    3131    divEvents: null, 
     32     
     33    /** Whether or not Pan icons will be displayed  
     34     *   Default is true 
     35     *  
     36     * @type Boolean 
     37     */ 
     38    showPan: true, 
     39     
     40    /** Whether or not ZoomBar will be displayed  
     41     *   Default is true 
     42     *  
     43     * @type Boolean 
     44     */ 
     45    showZoomBar: true, 
    3246 
    3347    initialize: function() { 
    3448        OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments); 
     
    88102 
    89103        var sz = new OpenLayers.Size(18,18); 
    90104        var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); 
    91  
    92         this._addButton("panup", "north-mini.png", centered, sz); 
    93         px.y = centered.y+sz.h; 
    94         this._addButton("panleft", "west-mini.png", px, sz); 
    95         this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz); 
    96         this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); 
    97         this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); 
    98         centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); 
    99         this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); 
     105        if(this.showPan){ 
     106            this._addButton("panup", "north-mini.png", centered, sz); 
     107            px.y = centered.y+sz.h; 
     108            this._addButton("panleft", "west-mini.png", px, sz); 
     109            this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz); 
     110            this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); 
     111        } 
     112        if(this.showZoomBar){ 
     113            this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); 
     114            centered = this._addZoomBar(centered.add(0, sz.h*4 + 5)); 
     115            this._addButton("zoomout", "zoom-minus-mini.png", centered, sz); 
     116        } 
    100117        return this.div; 
    101118    }, 
    102119