Handle cases where the x-axis distance cannot be calculated
This commit is contained in:
@@ -43,9 +43,12 @@ ol.control.ScaleLineUnits = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* A control displaying rough x-axis distances.
|
* A control displaying rough x-axis distances, calculated for the center of the
|
||||||
* By default it will show in the bottom left portion of the map, but this can
|
* viewport.
|
||||||
* be changed by using the css selector `.ol-scale-line`.
|
* No scale line will be shown when the x-axis distance cannot be calculated in
|
||||||
|
* the view projection (e.g. at or beyond the poles in EPSG:4326).
|
||||||
|
* By default the scale line will show in the bottom left portion of the map,
|
||||||
|
* but this can be changed by using the css selector `.ol-scale-line`.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.control.Control}
|
* @extends {ol.control.Control}
|
||||||
@@ -304,7 +307,11 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
|||||||
count = ol.control.ScaleLine.LEADING_DIGITS[i % 3] *
|
count = ol.control.ScaleLine.LEADING_DIGITS[i % 3] *
|
||||||
Math.pow(10, Math.floor(i / 3));
|
Math.pow(10, Math.floor(i / 3));
|
||||||
width = Math.round(count / pointResolution);
|
width = Math.round(count / pointResolution);
|
||||||
if (width >= this.minWidth_) {
|
if (isNaN(width)) {
|
||||||
|
goog.style.setElementShown(this.element_, false);
|
||||||
|
this.renderedVisible_ = false;
|
||||||
|
return;
|
||||||
|
} else if (width >= this.minWidth_) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
|
|||||||
Reference in New Issue
Block a user