OpenLayers OpenLayers

Changeset 6514

Show
Ignore:
Timestamp:
03/13/08 00:20:53 (6 months ago)
Author:
crschmidt
Message:

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)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js

    r6331 r6514  
    4949     */ 
    5050    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, 
    5165 
    5266    /**  
     
    133147        } 
    134148 
    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        } 
    148167        return this.div; 
    149168    }, 
  • trunk/openlayers/tests/Control/test_PanZoomBar.html

    r4059 r6514  
    55    var map;  
    66    function test_01_Control_PanZoomBar_constructor (t) { 
    7         t.plan( 4 ); 
     7         
     8        t.plan( 6 ); 
     9         
    810     
    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}); 
    1012        t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" ); 
    1113        t.eq( control.displayClass,  "olControlPanZoomBar", "displayClass is correct" ); 
    1214        t.eq( control.position.x, 100, "PanZoom X Set correctly.");  
    1315        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         
    1419    } 
    1520    function test_02_Control_PanZoomBar_addControl (t) { 
    16         t.plan( 8 ); 
     21        t.plan( 10 ); 
    1722        map = new OpenLayers.Map('map', {controls:[]}); 
    1823        var layer = new OpenLayers.Layer.WMS("Test Layer",  
     
    2025            {map: "/mapdata/vmap_wms.map", layers: "basic"}); 
    2126        map.addLayer(layer); 
    22         control = new OpenLayers.Control.PanZoomBar(); 
     27        control = new OpenLayers.Control.PanZoomBar({showPan: false, showZoomBar: false}); 
    2328        t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" ); 
    2429        t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" ); 
     
    2934        t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), 1001, "Viewport div contains control div" ); 
    3035        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"); 
    3137 
    3238        var control2 = new OpenLayers.Control.PanZoomBar(); 
    3339        map.addControl(control2, new OpenLayers.Pixel(100,100)); 
    3440        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"); 
    3542    } 
    3643