From 8b759ab1d61da53614fc123f601776988f8154a0 Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Wed, 19 Mar 2008 21:09:53 +0000 Subject: [PATCH] Closes #1451: change test to be (hopefully) map unit independent. r=crschmidt. git-svn-id: http://svn.openlayers.org/trunk/openlayers@6557 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/ScaleLine.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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);