Skip to content

Commit

Permalink
fix: useMeasure distance should have format option, same as `area…
Browse files Browse the repository at this point in the history
…` and `height`
  • Loading branch information
s3xysteak committed Oct 23, 2024
1 parent 884012a commit 44cbff0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/composables/useMeasure/src/distance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 44cbff0

Please sign in to comment.