From 44cbff0a2582ad89ba466ff0c34aa74fb82a3e94 Mon Sep 17 00:00:00 2001 From: s3xysteak Date: Wed, 23 Oct 2024 13:56:14 +0800 Subject: [PATCH] fix: useMeasure `distance` should have `format` option, same as `area` and `height` --- src/core/composables/useMeasure/src/distance.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/composables/useMeasure/src/distance.ts b/src/core/composables/useMeasure/src/distance.ts index 174ec7d..86e7e67 100644 --- a/src/core/composables/useMeasure/src/distance.ts +++ b/src/core/composables/useMeasure/src/distance.ts @@ -6,6 +6,7 @@ import { defineColor, editEntity, syncEntityCollection, useEventHandler } from ' import { pickPosition as _pickPosition } from '../utils' export interface DistanceOptions { + format?: (area: number) => string lineEntityProps?: Cesium.Entity.ConstructorOptions startEntityProps?: Cesium.Entity.ConstructorOptions turnEntityProps?: Cesium.Entity.ConstructorOptions @@ -75,6 +76,7 @@ export function distance(options: DistanceOptions = {}): DistanceReturn { turnEntityProps = {}, endEntityProps = {}, closeEntityProps = {}, + format = num => `Sum length: ${num.toFixed(2)}m`, } = options const state = ref(false) @@ -195,7 +197,7 @@ export function distance(options: DistanceOptions = {}): DistanceReturn { entities.add(editEntity({ position: pos, label: { - text: `Sum length: ${__fullLength.value.toFixed(2)}m`, + text: format(__fullLength.value), }, }, initialEntityProps, endEntityProps)) entities.add(editEntity({