OpenLayers OpenLayers

Changeset 7374

Show
Ignore:
Timestamp:
06/18/08 04:57:02 (2 months ago)
Author:
pgiraud
Message:

add a map getUnits method, r=ahocevar (Closes 1591)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/projected-map.html

    r7095 r7374  
    4848            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 
    4949            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
     50            map.addControl(new OpenLayers.Control.ScaleLine()); 
    5051        } 
    5152    </script> 
  • trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js

    r6810 r7374  
    496496        // The base layer for overview map needs to be in the same projection 
    497497        // as the base layer for the main map.  This should be made more robust. 
    498         if(this.map.units != 'degrees') { 
     498        if(this.map.getUnits() != 'degrees') { 
    499499            if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { 
    500500                alert(OpenLayers.i18n("sameProjection")); 
  • trunk/openlayers/lib/OpenLayers/Control/ScaleLine.js

    r6727 r7374  
    154154        } 
    155155 
    156         var curMapUnits = this.map.units
     156        var curMapUnits = this.map.getUnits()
    157157        var inches = OpenLayers.INCHES_PER_UNIT; 
    158158 
  • trunk/openlayers/lib/OpenLayers/Map.js

    r7311 r7374  
    17641764    }, 
    17651765 
     1766    /** 
     1767     * APIMethod: getUnits 
     1768     *  
     1769     * Returns: 
     1770     * {Float} The current units of the map.  
     1771     *         If no baselayer is set, returns null. 
     1772     */ 
     1773    getUnits: function () { 
     1774        var units = null; 
     1775        if (this.baseLayer != null) { 
     1776            units = this.baseLayer.units; 
     1777        } 
     1778        return units; 
     1779    }, 
     1780 
    17661781     /** 
    17671782      * APIMethod: getScale 
  • trunk/openlayers/tests/Control/ScaleLine.html

    r6719 r7374  
    8787        t.eq(control.div.firstChild.style.visibility, "visible", "top scale is present."); 
    8888        t.eq(control.div.lastChild.style.visibility, "visible", "bottom scale is present."); 
    89         t.eq(control.div.firstChild.innerHTML, "20000 km", "top scale has correct text."); 
    90         t.eq(control.div.lastChild.innerHTML, "20000 mi", "bottom scale has correct text."); 
     89        t.eq(control.div.firstChild.innerHTML, "200 m", "top scale has correct text."); 
     90        t.eq(control.div.lastChild.innerHTML, "1000 ft", "bottom scale has correct text."); 
    9191        map.destroy(); 
    9292    } 
  • trunk/openlayers/tests/Map.html

    r6724 r7374  
    10011001        map.destroy(); 
    10021002    } 
     1003     
     1004    function test_Map_getUnits(t) { 
     1005        t.plan(2); 
     1006        var map = new OpenLayers.Map("map"); 
     1007        var units = map.getUnits(); 
     1008        t.eq(units, null, "getUnits returns null for no base layer"); 
     1009         
     1010        var layer = new OpenLayers.Layer("test", { 
     1011            isBaseLayer: true, 
     1012            units: 'foo' 
     1013        }); 
     1014        map.addLayer(layer); 
     1015        var units = map.getUnits(); 
     1016        t.eq(units, 'foo', "getUnits returns the base layer units property"); 
     1017        layer.destroy(); 
     1018        map.destroy(); 
     1019    } 
    10031020 
    10041021    function test_Map_destroy (t) {