Skip to content

worldwind-ui API / worldwind-kit / computeScaleBar

Function: computeScaleBar() ​

computeScaleBar(metersPerPixelValue, options?): ScaleBarState | null

Defined in: kit/src/scale.ts:73

Picks a round distance (1, 2 or 5 times a power of ten in the chosen unit) that fits in maxWidth pixels at the given resolution.

Parameters ​

metersPerPixelValue ​

number

options? ​

ScaleBarOptions = {}

Returns ​

ScaleBarState | null

Example ​

ts
computeScaleBar(10, { maxWidth: 120 }); // { meters: 1000, pixels: 100, label: '1 km', ... }

MIT licensed. Not affiliated with NASA; WorldWind is NASA's open-source virtual globe.