OpenLayers OpenLayers

Ticket #1451: ScaleLine.patch

File ScaleLine.patch, 1.3 kB (added by pspencer, 8 months ago)

patch ScaleLine to accommodate different map units.

  • lib/OpenLayers/Control/ScaleLine.js

    old new  
    154154            return; 
    155155        } 
    156156 
     157        var curMapUnits = this.map.units; 
     158        var inches = OpenLayers.INCHES_PER_UNIT; 
     159 
    157160        // convert maxWidth to map units 
    158         var maxSizeData = this.maxWidth * res;   
     161        var maxSizeData = this.maxWidth * res * inches[curMapUnits];   
    159162 
    160163        // decide whether to use large or small scale units      
    161164        var topUnits; 
    162165        var bottomUnits; 
    163         if(maxSizeData > 0.1) { 
     166        if(maxSizeData > 100000) { 
    164167            topUnits = this.topOutUnits; 
    165168            bottomUnits = this.bottomOutUnits; 
    166169        } else { 
     
    169172        } 
    170173 
    171174        // and to map units units 
    172         var curMapUnits = this.map.units; 
    173         var inches = OpenLayers.INCHES_PER_UNIT; 
    174         var topMax = maxSizeData * inches[curMapUnits] / inches[topUnits]; 
    175         var bottomMax = maxSizeData * inches[curMapUnits] / inches[bottomUnits]; 
     175        var topMax = maxSizeData / inches[topUnits]; 
     176        var bottomMax = maxSizeData / inches[bottomUnits]; 
    176177 
    177178        // now trim this down to useful block length 
    178179        var topRounded = this.getBarLen(topMax);