diff --git a/src/Obj/Base/BatchModel/index.js b/src/Obj/Base/BatchModel/index.js index a42c94e..38b5140 100644 --- a/src/Obj/Base/BatchModel/index.js +++ b/src/Obj/Base/BatchModel/index.js @@ -5,6 +5,7 @@ import Dialog from '../../Element/Dialog'; import { html } from "./_element"; import EventBinding from '../../Element/Dialog/eventBinding'; import Base from "../index"; +import Tools from "../../../Tools"; import { syncData } from '../../../Global/MultiViewportMode' import Model from '../BaseSource/BaseModel/Model' import { legp } from '../../Element/datalist' @@ -13,7 +14,7 @@ import DrawPolyline from '../../../Draw/drawPolyline' import DrawPolygon from '../../../Draw/drawPolygon' import DrawThreeRect from '../../../Draw/drawThreeRect' import DrawPoint from '../../../Draw/drawPoint' -import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' +import { setActiveViewer, closeRotateAround, closeViewFollow, CesiumContainer } from '../../../Global/global' import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' @@ -46,6 +47,7 @@ class BatchModel extends Base { this._elms = {}; this.pointArr = [] this.sdk.addIncetance(this.options.id, this) + let tools = new Tools(sdk) // BatchModel.computeDis(this) // if (this.options.positions.length > 0 || this.options.positions.lng) { if ((options.type && options.spacing != undefined) || options.type == '点') { @@ -67,6 +69,32 @@ class BatchModel extends Base { } Draw && Draw.start((a, positions) => { this.options.positions = positions; + //判断范围是否过大 + if (options.type == '面') { + let posi = positions.map(v => { + return Cesium.Cartesian3.fromDegrees(v.lng, v.lat) + }) + let dis1 = Cesium.Cartesian3.distance(posi[0], posi[1]) + let dis2 = Cesium.Cartesian3.distance(posi[1], posi[2]) + let num1 = dis1 / options.spacing + let num2 = dis2 / options.spacing + if (num1 * num2 > 100) { + tools.message({ type: 'warning', text: '数量大于100,请重新绘制' }) + return; + } + } else if (options.type == '线') { + let posi = positions.map(v => { + return Cesium.Cartesian3.fromDegrees(v.lng, v.lat) + }) + let dis = 0 + for (let i = 0; i < posi.length - 2; i++) { + dis += Cesium.Cartesian3.distance(posi[i], posi[i + 1]) + } + if (dis / options.spacing > 100) { + tools.message({ type: 'warning', text: '数量大于100,请重新绘制' }) + return; + } + } // this.callback(this.options); (this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this) }) diff --git a/src/Tools/index.js b/src/Tools/index.js index 7bb0c14..c5b2466 100644 --- a/src/Tools/index.js +++ b/src/Tools/index.js @@ -1493,7 +1493,7 @@ class Tools { } } - message(option={}) { + message(option = {}) { let type = option.type || 'success' let text = option.text || '' let duration = option.duration || 1500 @@ -1504,9 +1504,16 @@ class Tools { } message = document.createElement('div') message.id = 'YJ-custom-message' - message.innerHTML = ` + if (type == 'success') { + message.innerHTML = ` ${text} ` + } else if (type == 'warning') { + message.innerHTML = ` + ${text} + ` + } + document.body.appendChild(message) message.classList.add(type) } diff --git a/static/custom/css/index.css b/static/custom/css/index.css index a8221a2..ddc31cf 100644 --- a/static/custom/css/index.css +++ b/static/custom/css/index.css @@ -3799,6 +3799,10 @@ background-color: #f0f9eb; color: rgb(82, 196, 26); } +#YJ-custom-message.warning { + background-color: #fdf6ec; + color: #e6a23c; +} /* 滑入动画 */ @keyframes YJ-custom-message-slideDown { @@ -3815,4 +3819,4 @@ top: -200px /* 移回顶部外 */ } -} \ No newline at end of file +}