直接上代码
/*
* 缓冲区显示
*/
var CesiumBufferUtil = function (viewer) {
this.viewer = viewer
this.handler = null;
this.positions = [];
this.isActive = false;
this.isDrawing = false;
this.viewEntities = []; // 点线面回显
this.bufferEntities = [];
this.type = 'Point'; //默认为点
this.radius = 1; //单位 km
}
/**
*
* @param {Object} options type类型 Point Line Polygon ; radius Number 半径
*/
CesiumBufferUtil.prototype.active = function (options) {
this.lastType = this.type; //记录上次操作的类型 便于清除结果
this.type = options.type || 'Point';
this.radius = options.radius || 1;
if (this.type === 'Point') {
this.initPointHandler()
}
if (this.type === 'Line') {
this.initLineHandler()
}
if (this.type === 'Polygon') {
this.initPolygonHandler()
}
}
/**
* 互斥 清除最后一个
*/
CesiumBufferUtil.prototype.removeLastOpereate = function () {
if (this.isDrawing) {