Skip to main content
Version: v2

getDistanceUnit

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Returns whether the current distance unit is metric or imperial. This method is to get the units set by the user, not to represent the units of the data, the data units refer to the interface description of the corresponding data.

Type​

function getDistanceUnit(): Result

Parameters​

Result​

TypeDescription
numberDistance units, value refer to distance unit constants

Constants​

Distance unit constants​

ConstantDescriptionAPI_LEVEL
DISTANCE_UNIT_METRICmetric system2.0
DISTANCE_UNIT_IMPERIALimperial system2.0

Example​

import { getDistanceUnit, DISTANCE_UNIT_METRIC } from '@zos/settings'

const distanceUnit = getDistanceUnit()

if (distanceUnit === DISTANCE_UNIT_METRIC) {
console.log('metric')
}