Skip to content

Commit

Permalink
Merge pull request #15453 from sunilkpai/add-nanometer-to-scaleline
Browse files Browse the repository at this point in the history
Add nanometer to scaleline
  • Loading branch information
ahocevar committed Dec 30, 2023
2 parents 45bbb1c + 2c6ff40 commit ee9908a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ol/control/ScaleLine.js
Expand Up @@ -284,7 +284,10 @@ class ScaleLine extends Control {
pointResolution /= 1852;
suffix = 'NM';
} else if (units == 'metric') {
if (nominalCount < 0.001) {
if (nominalCount < 1e-6) {
suffix = 'nm';
pointResolution *= 1e9;
} else if (nominalCount < 0.001) {
suffix = 'μm';
pointResolution *= 1000000;
} else if (nominalCount < 1) {
Expand Down
3 changes: 3 additions & 0 deletions test/browser/spec/ol/control/scaleline.test.js
Expand Up @@ -504,6 +504,9 @@ describe('ol.control.ScaleLine', function () {
let mapView;

const getMetricUnit = function (zoom) {
if (zoom > 40) {
return 'nm';
}
if (zoom > 30) {
return 'μm';
}
Expand Down

0 comments on commit ee9908a

Please sign in to comment.