Merge pull request #2628 from fredj/scale-line

Take the 'us' and 'nautical' units into account in scale line control
This commit is contained in:
Frédéric Junod
2014-08-26 11:03:48 +02:00
2 changed files with 9 additions and 3 deletions

View File

@@ -27,7 +27,9 @@
<div id="map" class="map"></div>
<select id="units">
<option value="degrees">degrees</option>
<option value="imperial">imperial</option>
<option value="imperial">imperial inch</option>
<option value="us">us inch</option>
<option value="nautical">nautical mile</option>
<option value="metric">metric</option>
</select>
</div>

View File

@@ -213,7 +213,9 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
var units = this.getUnits();
if (projectionUnits == ol.proj.Units.DEGREES &&
(units == ol.control.ScaleLineUnits.METRIC ||
units == ol.control.ScaleLineUnits.IMPERIAL)) {
units == ol.control.ScaleLineUnits.IMPERIAL ||
units == ol.control.ScaleLineUnits.US ||
units == ol.control.ScaleLineUnits.NAUTICAL)) {
// Convert pointResolution from degrees to meters
this.toEPSG4326_ = null;
@@ -244,7 +246,9 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
goog.asserts.assert(
((units == ol.control.ScaleLineUnits.METRIC ||
units == ol.control.ScaleLineUnits.IMPERIAL) &&
units == ol.control.ScaleLineUnits.IMPERIAL ||
units == ol.control.ScaleLineUnits.US ||
units == ol.control.ScaleLineUnits.NAUTICAL) &&
projectionUnits == ol.proj.Units.METERS) ||
(units == ol.control.ScaleLineUnits.DEGREES &&
projectionUnits == ol.proj.Units.DEGREES));