Skip to content

Commit

Permalink
Added nautical miles unit to ScaleControl
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Mairesse authored and jfirebaugh committed Sep 6, 2017
1 parent 9300b2b commit a32fe3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ui/control/scale_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type Map from '../map';
* @implements {IControl}
* @param {Object} [options]
* @param {number} [options.maxWidth='150'] The maximum length of the scale control in pixels.
* @param {string} [options.unit='metric'] Unit of the distance (`'imperial'` or `'metric'`).
* @param {string} [options.unit='metric'] Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).
* @example
* map.addControl(new mapboxgl.ScaleControl({
* maxWidth: 80,
Expand Down Expand Up @@ -78,6 +78,9 @@ function updateScale(map, container, options) {
} else {
setScale(container, maxWidth, maxFeet, 'ft');
}
} else if (options && options.unit === 'nautical') {
const maxNauticals = maxMeters / 1852;
setScale(container, maxWidth, maxNauticals, 'nm');
} else {
setScale(container, maxWidth, maxMeters, 'm');
}
Expand Down

0 comments on commit a32fe3b

Please sign in to comment.