diff --git a/lib/OpenLayers/Control/ScaleLine.js b/lib/OpenLayers/Control/ScaleLine.js index 935d653a95..9fc243bf71 100644 --- a/lib/OpenLayers/Control/ScaleLine.js +++ b/lib/OpenLayers/Control/ScaleLine.js @@ -154,13 +154,16 @@ OpenLayers.Control.ScaleLine = OpenLayers.Class(OpenLayers.Control, { return; } + var curMapUnits = this.map.units; + var inches = OpenLayers.INCHES_PER_UNIT; + // convert maxWidth to map units - var maxSizeData = this.maxWidth * res; + var maxSizeData = this.maxWidth * res * inches[curMapUnits]; // decide whether to use large or small scale units var topUnits; var bottomUnits; - if(maxSizeData > 0.1) { + if(maxSizeData > 100000) { topUnits = this.topOutUnits; bottomUnits = this.bottomOutUnits; } else { @@ -169,10 +172,8 @@ OpenLayers.Control.ScaleLine = OpenLayers.Class(OpenLayers.Control, { } // and to map units units - var curMapUnits = this.map.units; - var inches = OpenLayers.INCHES_PER_UNIT; - var topMax = maxSizeData * inches[curMapUnits] / inches[topUnits]; - var bottomMax = maxSizeData * inches[curMapUnits] / inches[bottomUnits]; + var topMax = maxSizeData / inches[topUnits]; + var bottomMax = maxSizeData / inches[bottomUnits]; // now trim this down to useful block length var topRounded = this.getBarLen(topMax);