MeasureViewModel

new IonSdkMeasurements.MeasureViewModel(options)

A widget for making ephemeral measurements.
Name Type Description
options Object An object with the following properties:
Name Type Default Description
scene Scene The scene
units MeasureUnits optional The units of measurement
locale String optional The BCP 47 language tag string customizing language-sensitive number formatting. If undefined, the runtime's default locale is used. See the Intl page on MDN
primitives PrimitiveCollection optional A collection in which to store the measurement primitives
measurements Array optional An array of measurement constructors or descriptor objects specifying which tools to include, e.g. [DistanceMeasurement, { type: DistanceMeasurement, showComponentLines: true }, VerticalMeasurement]. Defaults to the standard measurement set.
cursor MeasurementCursor MeasurementCursor.DEFAULT optional The cursor style to use when a measurement tool is active.

Members

expanded : Boolean

Gets and sets whether the measurement toolbar is expanded.
Default Value: false

instructionsVisible : Boolean

Gets and sets whether the instructions are visible.
Default Value: false

readonly measurements : Array.<Measurement>

Gets the array of available measurement types.

readonly scene : Scene

Gets the scene.

selectedMeasurement : Measurement

Gets or sets the currently selected measurement. This property is observable.
Default Value: undefined

units : MeasureUnits

Gets the selected unit of measurement.

Methods

destroy()

Destroys the widget view model.

isDestroyed()Boolean

Returns:
true if the object has been destroyed, false otherwise.

onMeasurementStateChange(callback)function

Registers a callback that is invoked whenever the measurement state changes, so an external UI can stay in sync. The callback receives no arguments and fires on: a measurement's handleClick, handleDoubleClick, and handleKeyDown (if defined), the MultipleDistanceMeasurement measurementCompleted and measurementsCleared events, and MeasureViewModel#reset.
Name Type Description
callback function The function to call when the measurement state changes.
Returns:
A function that removes the registered callback. Call it to unsubscribe when the listener is no longer needed to avoid stale callbacks and memory leaks.

reset()

Resets the widget.

toggleActive()

Toggles the state of the toolbar.

toggleInstructions()

Toggles the visibility of the instructions panel.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.