MeasureHandler

new Cesium.MeasureHandler(viewer, mode, clampMode)

Measurement processor class.
Name Type Description
viewer Viewer Specify the view used for measurement.
mode MeasureMode Specify the measurement mode.
clampMode ClampMode Specify the style of geometric objects (sticking to the ground, sticking to objects)
Example:
var handler = new MeasureHandler(viewer,Cesium.MeasureMode.Distance);
handler.activate();
handler.measureEvt.addEventListener(function(obj){
    console.log(obj);
});
See:

Members

activeEvt : Event

Activate the event and listen to the current event to get the status of the processor.

areaLabel : Entity

When the measurement mode is Area, use this label entity object areaLabel to display the area measurement result.

capturePointColor : Color

Get or set the color of the point cloud capture point during measurement.

capturePointSize : Number

Get or set the size of the point cloud capture point during measurement.

clampMode : ClampMode

Post object mode.

disLabel : Entity

When the measurement mode is Distance, use this label entity object disLabel to display the space distance measurement result.

enableDepthTest : Boolean

Set whether the depth detection is enabled for the drawing object. It is enabled by default.

fillColor : position

Gets or sets the fill color of the specified geometric object during measurement.

hLabel : Entity

When the measurement mode is DVH, use this label entity object hLabel to display the horizontal distance measurement result.

lineColor : position

获取或设置量算时指定几何对象的线颜色。

lineDisplayType : Number

Gets or sets the type of measurement timeline.

lineWidth : position

Gets or sets the line width of the specified geometric object during measurement.

measureEvt : Event

Measure events, monitor current events to obtain measurement results. When the measurement mode is MeasureMode.Distance, the callback result is {distance: distance}. When the measurement mode is MeasureMode.Area, the callback result is {area: area, positions: positions}. When the measurement mode is MeasureMode.DVH, the callback result is {distance: distance,verticalHeight: vHeight,horizontalDistance: hHeight}.
Example:
var handler = new Cesium.MeasureHandler(viewer,Cesium.MeasureMode.Area);
handler.measureEvt.addEventListener(function(result){
                    var area = result.area > 1000000 ? result.area/1000000 + 'km²' : result.area + '㎡'
                    handler.areaLabel.text = 'area:' + area;
                });

vLabel : Entity

When the measurement mode is DVH or Height, use this label entity object vLabel to display the vertical height measurement result.

Methods

staticCesium.MeasureHandler.computeArea(positions)

Calculate the area based on a series of Cartesian coordinate points, in m2 (square meters).
Name Type Description
positions The coordinates of each point on the surface

activate()

Activate the measurement processor.

clear()

Clear all elements related to measurement.

deactivate()

Turn off the measurement processor.