Merge pull request #3307 from ahocevar/scaleline-units
Handle all non-degree units in ol.control.ScaleLine
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user