使用
在项目中引入Cesium.js
然后引入 cesium-measure.js 即可
let viewer = new Cesium.Viewer("viewerContainer")
let measure = new Cesium.Measure(viewer)
// 空间距离
measure.drawLineMeasureGraphics({ clampToGround: clampToGround, callback: () => { } });
// 空间面积
measure.drawAreaMeasureGraphics({ clampToGround: clampToGround, callback: () => { } });
// 三维量测
measure.drawTrianglesMeasureGraphics({ callback: () => { } });
// 清除
measure._drawLayer.entities.removeAll();
测量插件完整代码
; if (typeof Cesium !== 'undefined')
/**
* @author zhangti
* @param viewer {object} 三维对象
* @param options {object} 初始化参数
* @constructor
*/
Cesium.Measure = (function (Cesium) {
/**
* 绘制对象
* @param viewer
* @param options
* @constructor
*/
function _(viewer, options = {}) {
if (viewer && viewer instanceof Cesium.Viewer) {
this._drawLayer = new