diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index d6fa643b4f..a82f443bbf 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -139,19 +139,12 @@ ol.Projection.prototype.getUnits = function() { /** - * Get the amount of meters per unit of this projection. - * @return {number} Meters. + * Get the amount of meters per unit of this projection. If the projection is + * not configured with a units identifier, the return is `undefined`. + * @return {number|undefined} Meters. */ ol.Projection.prototype.getMetersPerUnit = function() { - var metersPerUnit; - if (!goog.isNull(this.units_)) { - metersPerUnit = ol.METERS_PER_UNIT[this.units_]; - } else { - if (this instanceof ol.Proj4jsProjection_) { - metersPerUnit = this.getProj4jsProj().to_meter; - } - } - return metersPerUnit; + return ol.METERS_PER_UNIT[this.units_]; }; @@ -231,6 +224,18 @@ ol.Proj4jsProjection_ = function(proj4jsProj, options) { goog.inherits(ol.Proj4jsProjection_, ol.Projection); +/** + * @inheritDoc + */ +ol.Proj4jsProjection_.prototype.getMetersPerUnit = function() { + var metersPerUnit = this.proj4jsProj_.to_meter; + if (!goog.isDef(metersPerUnit)) { + metersPerUnit = ol.METERS_PER_UNIT[this.units_]; + } + return metersPerUnit; +}; + + /** * @inheritDoc */