diff --git a/src/ol/control/scalelinecontrol.js b/src/ol/control/scalelinecontrol.js index 039657828a..7efa6247f0 100644 --- a/src/ol/control/scalelinecontrol.js +++ b/src/ol/control/scalelinecontrol.js @@ -13,6 +13,7 @@ goog.require('ol.TransformFunction'); goog.require('ol.control.Control'); goog.require('ol.css'); goog.require('ol.proj'); +goog.require('ol.proj.METERS_PER_UNIT'); goog.require('ol.proj.Units'); goog.require('ol.sphere.NORMAL'); @@ -227,20 +228,18 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { pointResolution *= Math.PI * cosLatitude * ol.sphere.NORMAL.radius / 180; projectionUnits = ol.proj.Units.METERS; - } else if ((projectionUnits == ol.proj.Units.FEET || - projectionUnits == ol.proj.Units.METERS) && + } else if (projectionUnits != ol.proj.Units.DEGREES && units == ol.control.ScaleLineUnits.DEGREES) { - // Convert pointResolution from meters or feet to degrees + // Convert pointResolution from other units to degrees if (goog.isNull(this.toEPSG4326_)) { this.toEPSG4326_ = ol.proj.getTransformFromProjections( projection, ol.proj.get('EPSG:4326')); } cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1])); var radius = ol.sphere.NORMAL.radius; - if (projectionUnits == ol.proj.Units.FEET) { - radius /= 0.3048; - } + goog.asserts.assert(goog.isDef(ol.proj.METERS_PER_UNIT[projectionUnits])); + radius /= ol.proj.METERS_PER_UNIT[projectionUnits]; pointResolution *= 180 / (Math.PI * cosLatitude * radius); projectionUnits = ol.proj.Units.DEGREES;