|
@@ -270,6 +270,8 @@ class DrawTools {
|
|
/* 获取画布的宽度和高度 */
|
|
/* 获取画布的宽度和高度 */
|
|
this._canvasWidth = this._viewer.scene.canvas.width;
|
|
this._canvasWidth = this._viewer.scene.canvas.width;
|
|
this._canvasHeight = this._viewer.scene.canvas.height;
|
|
this._canvasHeight = this._viewer.scene.canvas.height;
|
|
|
|
+ /* 获取当前运行模式 */
|
|
|
|
+ this._windowType = this._checkAppOrWeb();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -879,7 +881,7 @@ class DrawTools {
|
|
this._sketchPoints = [];
|
|
this._sketchPoints = [];
|
|
this._sketchOutputPoints = [];
|
|
this._sketchOutputPoints = [];
|
|
this._sketchWallHeights = [];
|
|
this._sketchWallHeights = [];
|
|
- /* 重置编辑实体 */
|
|
|
|
|
|
+ /* ���������������������������������������������������������������������������置编辑实体 */
|
|
this._drawEntity = undefined;
|
|
this._drawEntity = undefined;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -889,7 +891,7 @@ class DrawTools {
|
|
*/
|
|
*/
|
|
Object.assign(DrawTools.prototype, {
|
|
Object.assign(DrawTools.prototype, {
|
|
/**
|
|
/**
|
|
- * ���������������������������������置点击点显示�����标记
|
|
|
|
|
|
+ * �����������������������������������������������������������置点击点显示�����标记
|
|
* @param {JSNO} options 配置项
|
|
* @param {JSNO} options 配置项
|
|
* @param {String} options.lineLabel 线点文字标注
|
|
* @param {String} options.lineLabel 线点文字标注
|
|
* @param {String} options.polygonLabel 面点文字标注
|
|
* @param {String} options.polygonLabel 面点文字标注
|
|
@@ -1012,6 +1014,8 @@ Object.assign(DrawTools.prototype, {
|
|
_clearEvent: function(handler) {
|
|
_clearEvent: function(handler) {
|
|
/* 清理事件的同时 彻底清理提示标签 */
|
|
/* 清理事件的同时 彻底清理提示标签 */
|
|
this._endTooltip();
|
|
this._endTooltip();
|
|
|
|
+ /* 隐藏操作容器 */
|
|
|
|
+ this._removeOperationDom();
|
|
if (!handler) return;
|
|
if (!handler) return;
|
|
/* 干掉事件句柄 释放资源 */
|
|
/* 干掉事件句柄 释放资源 */
|
|
handler.destroy();
|
|
handler.destroy();
|
|
@@ -2022,6 +2026,8 @@ Object.assign(DrawTools.prototype, {
|
|
/* 监听输出 */
|
|
/* 监听输出 */
|
|
if (options.onAdded) options.onAdded(_self._sketchPoints, _self
|
|
if (options.onAdded) options.onAdded(_self._sketchPoints, _self
|
|
._sketchOutputPoints);
|
|
._sketchOutputPoints);
|
|
|
|
+ /* 添加操作容器 */
|
|
|
|
+ _self._createOperationDom();
|
|
})
|
|
})
|
|
/* 注册鼠标移动事件 */
|
|
/* 注册鼠标移动事件 */
|
|
this._registerMouseMoveEvent(handler, function(event) {
|
|
this._registerMouseMoveEvent(handler, function(event) {
|
|
@@ -2104,6 +2110,8 @@ Object.assign(DrawTools.prototype, {
|
|
_self._sketchOutputPoints.push(loc.gLocation);
|
|
_self._sketchOutputPoints.push(loc.gLocation);
|
|
/* 监听输出 */
|
|
/* 监听输出 */
|
|
if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
|
|
if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
|
|
|
|
+ /* 添加操作容器 */
|
|
|
|
+ _self._createOperationDom();
|
|
})
|
|
})
|
|
/* 注册鼠标移动事件 */
|
|
/* 注册鼠标移动事件 */
|
|
this._registerMouseMoveEvent(handler, function(event) {
|
|
this._registerMouseMoveEvent(handler, function(event) {
|
|
@@ -2264,6 +2272,8 @@ Object.assign(DrawTools.prototype, {
|
|
_self._sketchOutputPoints.push(loc.gLocation);
|
|
_self._sketchOutputPoints.push(loc.gLocation);
|
|
/* 监听输出 */
|
|
/* 监听输出 */
|
|
if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
|
|
if (options.onAdded) options.onAdded(_self._sketchPoints, _self._sketchOutputPoints);
|
|
|
|
+ /* 添加操作容器 */
|
|
|
|
+ _self._createOperationDom();
|
|
});
|
|
});
|
|
/* 注册鼠标移动事件 */
|
|
/* 注册鼠标移动事件 */
|
|
this._registerMouseMoveEvent(handler, function(event) {
|
|
this._registerMouseMoveEvent(handler, function(event) {
|
|
@@ -2412,8 +2422,7 @@ Object.assign(DrawTools.prototype, {
|
|
/* 创建正式矩形 */
|
|
/* 创建正式矩形 */
|
|
_self._updateRectangle(options.isEdit);
|
|
_self._updateRectangle(options.isEdit);
|
|
/* 干掉事件句柄 释放资源*/
|
|
/* 干掉事件句柄 释放资源*/
|
|
- handler.destroy();
|
|
|
|
- handler = null;
|
|
|
|
|
|
+ _self._clearEvent(handler);
|
|
/* 回调返回 */
|
|
/* 回调返回 */
|
|
if (options.onComplete) options.onComplete(_self._sketchOutputPoints);
|
|
if (options.onComplete) options.onComplete(_self._sketchOutputPoints);
|
|
}
|
|
}
|
|
@@ -2650,7 +2659,7 @@ Object.assign(DrawTools.prototype, {
|
|
Clear: function() {
|
|
Clear: function() {
|
|
/* 清理全部绘制内容 */
|
|
/* 清理全部绘制内容 */
|
|
this._clear(true);
|
|
this._clear(true);
|
|
- /* 结束编辑状态 */
|
|
|
|
|
|
+ /* 结���编���状��� */
|
|
this._unActivateEdit();
|
|
this._unActivateEdit();
|
|
/* 删除坐标轴 */
|
|
/* 删除坐标轴 */
|
|
this._removeCoorinateAxis();
|
|
this._removeCoorinateAxis();
|
|
@@ -2661,6 +2670,20 @@ Object.assign(DrawTools.prototype, {
|
|
*/
|
|
*/
|
|
sketchInit: function() {
|
|
sketchInit: function() {
|
|
this._clear(false);
|
|
this._clear(false);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 检测程序运行环境
|
|
|
|
+ * @return {DrawTools.RuntimeEnvironment}
|
|
|
|
+ */
|
|
|
|
+ _checkAppOrWeb() {
|
|
|
|
+ if (window.navigator.userAgent.match(
|
|
|
|
+ /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
|
|
+ )) {
|
|
|
|
+ return DrawTools.RuntimeEnvironment.App;
|
|
|
|
+ } else {
|
|
|
|
+ return DrawTools.RuntimeEnvironment.Web;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
@@ -2669,9 +2692,9 @@ Object.assign(DrawTools.prototype, {
|
|
*/
|
|
*/
|
|
Object.assign(DrawTools.prototype, {
|
|
Object.assign(DrawTools.prototype, {
|
|
/**
|
|
/**
|
|
- * 提���标���初���化
|
|
|
|
|
|
+ * 提示标签初始化
|
|
* @ignore 生成方法时不对外公开
|
|
* @ignore 生成方法时不对外公开
|
|
- * @param {String} text 显示的文本内���
|
|
|
|
|
|
+ * @param {String} text 显示的文本内容
|
|
* @param {JSON} mousePosition 鼠标位置
|
|
* @param {JSON} mousePosition 鼠标位置
|
|
*/
|
|
*/
|
|
_tooltipInit: function(text, mousePosition) {
|
|
_tooltipInit: function(text, mousePosition) {
|
|
@@ -4304,7 +4327,7 @@ Object.assign(DrawTools.prototype, {
|
|
var point1 = turf.point([strLoc.longitude, strLoc.latitude]);
|
|
var point1 = turf.point([strLoc.longitude, strLoc.latitude]);
|
|
var point2 = turf.point([endLoc.gLocation.lng, endLoc.gLocation.lat]);
|
|
var point2 = turf.point([endLoc.gLocation.lng, endLoc.gLocation.lat]);
|
|
var bearing = turf.bearing(point1, point2);
|
|
var bearing = turf.bearing(point1, point2);
|
|
- /* 计算亮点之间的距离 距离单位和是否计算高度*/
|
|
|
|
|
|
+ /* 计算亮点���间���距��� 距���单���和���否���算���度*/
|
|
var options = {
|
|
var options = {
|
|
units: 'kilometers',
|
|
units: 'kilometers',
|
|
calculateHeight: calculateHeight
|
|
calculateHeight: calculateHeight
|
|
@@ -4322,10 +4345,10 @@ Object.assign(DrawTools.prototype, {
|
|
/* 更新移动点数组 */
|
|
/* 更新移动点数组 */
|
|
this._ellipseOutlineCoordinates[i] = position.clone();
|
|
this._ellipseOutlineCoordinates[i] = position.clone();
|
|
}
|
|
}
|
|
- /* ���新中心���置数组 */
|
|
|
|
|
|
+ /* �������新中心���置数组 */
|
|
this._movePoint = endLoc.sLocation;
|
|
this._movePoint = endLoc.sLocation;
|
|
} else {
|
|
} else {
|
|
- /* 循环���理所有移动点 */
|
|
|
|
|
|
+ /* 循环处理所有移动点 */
|
|
for (let i = 0; i < this._startMovePoints.length; i++) {
|
|
for (let i = 0; i < this._startMovePoints.length; i++) {
|
|
/* 计算转换后的位置 */
|
|
/* 计算转换后的位置 */
|
|
let position = this._calculateTransformPosition(this._startMovePoints[i], distance, bearing,
|
|
let position = this._calculateTransformPosition(this._startMovePoints[i], distance, bearing,
|
|
@@ -4408,7 +4431,7 @@ Object.assign(DrawTools.prototype, {
|
|
._rectangleCoordinates[0], _self
|
|
._rectangleCoordinates[0], _self
|
|
._rectangleCoordinates[1], _self._rectangleCoordinates[2], _self
|
|
._rectangleCoordinates[1], _self._rectangleCoordinates[2], _self
|
|
._rectangleCoordinates[3]);
|
|
._rectangleCoordinates[3]);
|
|
- /* ��������������矩形有边界线 特殊处理 */
|
|
|
|
|
|
+ /* 判断矩形有边界线 特殊处理 */
|
|
if (_self._editEntity.polyline != undefined) {
|
|
if (_self._editEntity.polyline != undefined) {
|
|
_self._editEntity.polyline.positions = _self._rectangleOutlineCoordinates;
|
|
_self._editEntity.polyline.positions = _self._rectangleOutlineCoordinates;
|
|
}
|
|
}
|
|
@@ -4937,6 +4960,99 @@ Object.assign(DrawTools.prototype, {
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 操作按钮相关
|
|
|
|
+ */
|
|
|
|
+Object.assign(DrawTools.prototype, {
|
|
|
|
+ /**
|
|
|
|
+ * 初始化操作容器
|
|
|
|
+ */
|
|
|
|
+ _initOperationDom: function() {
|
|
|
|
+ let _self = this;
|
|
|
|
+ this._operationDomId = 'drawtools_operation_dom'
|
|
|
|
+ this._operationDom = document.getElementById(this._operationDomId);
|
|
|
|
+ /* 先执行移除操作 */
|
|
|
|
+ this._removeOperationDom()
|
|
|
|
+ /* 开始创建 */
|
|
|
|
+ this._operationDom = document.createElement('div');
|
|
|
|
+ this._operationDom.id = this._operationDomId;
|
|
|
|
+ this._operationDom.style.width = '80px';
|
|
|
|
+ this._operationDom.style.backgroundColor = 'rgba(0, 0, 0, 0.85)';
|
|
|
|
+ this._operationDom.style.borderRadius = '5px';
|
|
|
|
+ this._operationDom.style.display = 'flex';
|
|
|
|
+ this._operationDom.style.flexDirection = 'column';
|
|
|
|
+ this._operationDom.style.padding = '8px';
|
|
|
|
+ this._operationDom.style.justifyContent = 'center';
|
|
|
|
+ this._operationDom.style.position = 'absolute';
|
|
|
|
+ this._operationDom.style.bottom = '150px';
|
|
|
|
+ this._operationDom.style.right = '50px';
|
|
|
|
+ document.body.appendChild(this._operationDom);
|
|
|
|
+ /* 创建回退按钮 */
|
|
|
|
+ let btnUndo = document.createElement('button');
|
|
|
|
+ btnUndo.style.height = '30px';
|
|
|
|
+ btnUndo.style.marginBottom = '8px';
|
|
|
|
+ btnUndo.style.backgroundColor = 'rgba(52, 137, 255, 1.0)';
|
|
|
|
+ btnUndo.style.color = 'rgb(255, 255, 255)';
|
|
|
|
+ btnUndo.style.border = '0px solid red';
|
|
|
|
+ btnUndo.style.borderRadius = '5px';
|
|
|
|
+ btnUndo.innerHTML = '回退';
|
|
|
|
+ btnUndo.style.fontSize = '13px';
|
|
|
|
+ btnUndo.style.cursor = 'pointer';
|
|
|
|
+ this._operationDom.appendChild(btnUndo);
|
|
|
|
+ /* 创建完成按钮 */
|
|
|
|
+ let btnCompletion = document.createElement('button');
|
|
|
|
+ btnCompletion.style.height = '30px';
|
|
|
|
+ btnCompletion.style.backgroundColor = 'rgba(88, 185, 45, 1.0)';
|
|
|
|
+ btnCompletion.style.color = 'rgb(255, 255, 255)';
|
|
|
|
+ btnCompletion.style.border = '0px solid red';
|
|
|
|
+ btnCompletion.style.borderRadius = '5px';
|
|
|
|
+ btnCompletion.innerHTML = '完成';
|
|
|
|
+ btnCompletion.style.fontSize = '13px';
|
|
|
|
+ btnCompletion.style.cursor = 'pointer';
|
|
|
|
+ this._operationDom.appendChild(btnCompletion);
|
|
|
|
+ /* 添加事件 */
|
|
|
|
+ btnUndo.onclick = function() {
|
|
|
|
+ _self._console(_self._drawEventHandler, _self._drawEventHandler.isDestroyed());
|
|
|
|
+ if (_self._drawEventHandler !== undefined && _self._drawEventHandler.isDestroyed() ===
|
|
|
|
+ false) {
|
|
|
|
+ let mouseDownEvent = {
|
|
|
|
+ position: new Cesium.Cartesian2(300, 300),
|
|
|
|
+ }
|
|
|
|
+ let action = _self._drawEventHandler.getInputAction(Cesium.ScreenSpaceEventType
|
|
|
|
+ .RIGHT_CLICK);
|
|
|
|
+ action(mouseDownEvent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ btnCompletion.onclick = function() {
|
|
|
|
+ if (_self._drawEventHandler !== undefined && _self._drawEventHandler.isDestroyed() ===
|
|
|
|
+ false) {
|
|
|
|
+ let mouseDownEvent = {
|
|
|
|
+ position: new Cesium.Cartesian2(300, 300),
|
|
|
|
+ }
|
|
|
|
+ let action = _self._drawEventHandler.getInputAction(Cesium.ScreenSpaceEventType
|
|
|
|
+ .LEFT_DOUBLE_CLICK);
|
|
|
|
+ action(mouseDownEvent);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 移除操作容器
|
|
|
|
+ */
|
|
|
|
+ _removeOperationDom: function() {
|
|
|
|
+ if (this._operationDom !== null && this._operationDom !== undefined) {
|
|
|
|
+ document.body.removeChild(this._operationDom);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加操作容器
|
|
|
|
+ */
|
|
|
|
+ _createOperationDom: function() {
|
|
|
|
+ this._initOperationDom();
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+/**
|
|
* 绘制类型
|
|
* 绘制类型
|
|
*/
|
|
*/
|
|
DrawTools.DrawType = Object.freeze({
|
|
DrawTools.DrawType = Object.freeze({
|
|
@@ -5019,6 +5135,14 @@ DrawTools.PolygonType = Object.freeze({
|
|
HousePolygon: 'housePolygon', //拉伸贴地面
|
|
HousePolygon: 'housePolygon', //拉伸贴地面
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 运行环境类型
|
|
|
|
+ */
|
|
|
|
+DrawTools.RuntimeEnvironment = Object.freeze(({
|
|
|
|
+ App: 'app',
|
|
|
|
+ Web: 'web'
|
|
|
|
+}))
|
|
|
|
+
|
|
|
|
|
|
class WallMaterialProperty {
|
|
class WallMaterialProperty {
|
|
/**
|
|
/**
|