diff --git a/externs/olx.js b/externs/olx.js index 14579f32fe..64f8fe9f5a 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -1391,7 +1391,7 @@ olx.control.OverviewMapOptions.prototype.view; * minWidth: (number|undefined), * render: (function(ol.MapEvent)|undefined), * target: (Element|undefined), - * units: (ol.control.ScaleLine.Units|string|undefined)}} + * units: (ol.control.ScaleLineUnits|string|undefined)}} */ olx.control.ScaleLineOptions; @@ -1431,7 +1431,7 @@ olx.control.ScaleLineOptions.prototype.target; /** * Units. Default is `metric`. - * @type {ol.control.ScaleLine.Units|string|undefined} + * @type {ol.control.ScaleLineUnits|string|undefined} * @api stable */ olx.control.ScaleLineOptions.prototype.units; diff --git a/src/ol/control/scaleline.js b/src/ol/control/scaleline.js index debd1c6345..cd480115d1 100644 --- a/src/ol/control/scaleline.js +++ b/src/ol/control/scaleline.js @@ -4,6 +4,7 @@ goog.require('ol'); goog.require('ol.Object'); goog.require('ol.asserts'); goog.require('ol.control.Control'); +goog.require('ol.control.ScaleLineUnits'); goog.require('ol.css'); goog.require('ol.events'); goog.require('ol.proj'); @@ -88,8 +89,8 @@ ol.control.ScaleLine = function(opt_options) { this, ol.Object.getChangeEventType(ol.control.ScaleLine.Property_.UNITS), this.handleUnitsChanged_, this); - this.setUnits(/** @type {ol.control.ScaleLine.Units} */ (options.units) || - ol.control.ScaleLine.Units.METRIC); + this.setUnits(/** @type {ol.control.ScaleLineUnits} */ (options.units) || + ol.control.ScaleLineUnits.METRIC); }; ol.inherits(ol.control.ScaleLine, ol.control.Control); @@ -104,13 +105,13 @@ ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5]; /** * Return the units to use in the scale line. - * @return {ol.control.ScaleLine.Units|undefined} The units to use in the scale + * @return {ol.control.ScaleLineUnits|undefined} The units to use in the scale * line. * @observable * @api stable */ ol.control.ScaleLine.prototype.getUnits = function() { - return /** @type {ol.control.ScaleLine.Units|undefined} */ ( + return /** @type {ol.control.ScaleLineUnits|undefined} */ ( this.get(ol.control.ScaleLine.Property_.UNITS)); }; @@ -142,7 +143,7 @@ ol.control.ScaleLine.prototype.handleUnitsChanged_ = function() { /** * Set the units to use in the scale line. - * @param {ol.control.ScaleLine.Units} units The units to use in the scale line. + * @param {ol.control.ScaleLineUnits} units The units to use in the scale line. * @observable * @api stable */ @@ -175,7 +176,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { var nominalCount = this.minWidth_ * pointResolution; var suffix = ''; var units = this.getUnits(); - if (units == ol.control.ScaleLine.Units.DEGREES) { + if (units == ol.control.ScaleLineUnits.DEGREES) { var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES]; pointResolution /= metersPerDegree; if (nominalCount < metersPerDegree / 60) { @@ -187,7 +188,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { } else { suffix = '\u00b0'; // degrees } - } else if (units == ol.control.ScaleLine.Units.IMPERIAL) { + } else if (units == ol.control.ScaleLineUnits.IMPERIAL) { if (nominalCount < 0.9144) { suffix = 'in'; pointResolution /= 0.0254; @@ -198,10 +199,10 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { suffix = 'mi'; pointResolution /= 1609.344; } - } else if (units == ol.control.ScaleLine.Units.NAUTICAL) { + } else if (units == ol.control.ScaleLineUnits.NAUTICAL) { pointResolution /= 1852; suffix = 'nm'; - } else if (units == ol.control.ScaleLine.Units.METRIC) { + } else if (units == ol.control.ScaleLineUnits.METRIC) { if (nominalCount < 1) { suffix = 'mm'; pointResolution *= 1000; @@ -211,7 +212,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { suffix = 'km'; pointResolution /= 1000; } - } else if (units == ol.control.ScaleLine.Units.US) { + } else if (units == ol.control.ScaleLineUnits.US) { if (nominalCount < 0.9144) { suffix = 'in'; pointResolution *= 39.37; @@ -269,17 +270,3 @@ ol.control.ScaleLine.prototype.updateElement_ = function() { ol.control.ScaleLine.Property_ = { UNITS: 'units' }; - - -/** - * Units for the scale line. Supported values are `'degrees'`, `'imperial'`, - * `'nautical'`, `'metric'`, `'us'`. - * @enum {string} - */ -ol.control.ScaleLine.Units = { - DEGREES: 'degrees', - IMPERIAL: 'imperial', - NAUTICAL: 'nautical', - METRIC: 'metric', - US: 'us' -}; diff --git a/src/ol/control/scalelineunits.js b/src/ol/control/scalelineunits.js new file mode 100644 index 0000000000..308c45d6e7 --- /dev/null +++ b/src/ol/control/scalelineunits.js @@ -0,0 +1,14 @@ +goog.provide('ol.control.ScaleLineUnits'); + +/** + * Units for the scale line. Supported values are `'degrees'`, `'imperial'`, + * `'nautical'`, `'metric'`, `'us'`. + * @enum {string} + */ +ol.control.ScaleLineUnits = { + DEGREES: 'degrees', + IMPERIAL: 'imperial', + NAUTICAL: 'nautical', + METRIC: 'metric', + US: 'us' +};