批量模型数量判断并设置提示
This commit is contained in:
@ -5,6 +5,7 @@ import Dialog from '../../Element/Dialog';
|
|||||||
import { html } from "./_element";
|
import { html } from "./_element";
|
||||||
import EventBinding from '../../Element/Dialog/eventBinding';
|
import EventBinding from '../../Element/Dialog/eventBinding';
|
||||||
import Base from "../index";
|
import Base from "../index";
|
||||||
|
import Tools from "../../../Tools";
|
||||||
import { syncData } from '../../../Global/MultiViewportMode'
|
import { syncData } from '../../../Global/MultiViewportMode'
|
||||||
import Model from '../BaseSource/BaseModel/Model'
|
import Model from '../BaseSource/BaseModel/Model'
|
||||||
import { legp } from '../../Element/datalist'
|
import { legp } from '../../Element/datalist'
|
||||||
@ -13,7 +14,7 @@ import DrawPolyline from '../../../Draw/drawPolyline'
|
|||||||
import DrawPolygon from '../../../Draw/drawPolygon'
|
import DrawPolygon from '../../../Draw/drawPolygon'
|
||||||
import DrawThreeRect from '../../../Draw/drawThreeRect'
|
import DrawThreeRect from '../../../Draw/drawThreeRect'
|
||||||
import DrawPoint from '../../../Draw/drawPoint'
|
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'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ class BatchModel extends Base {
|
|||||||
this._elms = {};
|
this._elms = {};
|
||||||
this.pointArr = []
|
this.pointArr = []
|
||||||
this.sdk.addIncetance(this.options.id, this)
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
|
let tools = new Tools(sdk)
|
||||||
// BatchModel.computeDis(this)
|
// BatchModel.computeDis(this)
|
||||||
// if (this.options.positions.length > 0 || this.options.positions.lng) {
|
// if (this.options.positions.length > 0 || this.options.positions.lng) {
|
||||||
if ((options.type && options.spacing != undefined) || options.type == '点') {
|
if ((options.type && options.spacing != undefined) || options.type == '点') {
|
||||||
@ -67,6 +69,32 @@ class BatchModel extends Base {
|
|||||||
}
|
}
|
||||||
Draw && Draw.start((a, positions) => {
|
Draw && Draw.start((a, positions) => {
|
||||||
this.options.positions = 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.callback(this.options);
|
||||||
(this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this)
|
(this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this)
|
||||||
})
|
})
|
||||||
|
@ -1493,7 +1493,7 @@ class Tools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message(option={}) {
|
message(option = {}) {
|
||||||
let type = option.type || 'success'
|
let type = option.type || 'success'
|
||||||
let text = option.text || ''
|
let text = option.text || ''
|
||||||
let duration = option.duration || 1500
|
let duration = option.duration || 1500
|
||||||
@ -1504,9 +1504,16 @@ class Tools {
|
|||||||
}
|
}
|
||||||
message = document.createElement('div')
|
message = document.createElement('div')
|
||||||
message.id = 'YJ-custom-message'
|
message.id = 'YJ-custom-message'
|
||||||
message.innerHTML = `
|
if (type == 'success') {
|
||||||
|
message.innerHTML = `
|
||||||
<i><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755929961282" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5064" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M874.119618 149.859922A510.816461 510.816461 0 0 0 511.997 0.00208a509.910462 509.910462 0 0 0-362.119618 149.857842c-199.817789 199.679789-199.817789 524.581447 0 724.260236a509.969462 509.969462 0 0 0 362.119618 149.857842A508.872463 508.872463 0 0 0 874.119618 874.120158c199.836789-199.679789 199.836789-524.581447 0-724.260236zM814.94268 378.210681L470.999043 744.132295a15.359984 15.359984 0 0 1-5.887994 4.095996c-1.751998 1.180999-2.913997 2.362998-5.276994 2.913997a34.499964 34.499964 0 0 1-13.469986 2.914997 45.547952 45.547952 0 0 1-12.897986-2.303998l-4.095996-2.363997a45.291952 45.291952 0 0 1-7.009992-4.095996l-196.902793-193.789796a34.126964 34.126964 0 0 1-10.555989-25.186973c0-9.37399 3.583996-18.74698 9.98399-25.186974a36.429962 36.429962 0 0 1 50.372947 0l169.98382 167.423824L763.389735 330.220732a37.059961 37.059961 0 0 1 50.371947-1.732998 33.647965 33.647965 0 0 1 11.165988 25.186973 35.544963 35.544963 0 0 1-9.98399 24.575974v-0.04z m0 0" fill="#52C41A" p-id="5065"></path></svg></i>${text}
|
<i><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755929961282" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5064" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M874.119618 149.859922A510.816461 510.816461 0 0 0 511.997 0.00208a509.910462 509.910462 0 0 0-362.119618 149.857842c-199.817789 199.679789-199.817789 524.581447 0 724.260236a509.969462 509.969462 0 0 0 362.119618 149.857842A508.872463 508.872463 0 0 0 874.119618 874.120158c199.836789-199.679789 199.836789-524.581447 0-724.260236zM814.94268 378.210681L470.999043 744.132295a15.359984 15.359984 0 0 1-5.887994 4.095996c-1.751998 1.180999-2.913997 2.362998-5.276994 2.913997a34.499964 34.499964 0 0 1-13.469986 2.914997 45.547952 45.547952 0 0 1-12.897986-2.303998l-4.095996-2.363997a45.291952 45.291952 0 0 1-7.009992-4.095996l-196.902793-193.789796a34.126964 34.126964 0 0 1-10.555989-25.186973c0-9.37399 3.583996-18.74698 9.98399-25.186974a36.429962 36.429962 0 0 1 50.372947 0l169.98382 167.423824L763.389735 330.220732a37.059961 37.059961 0 0 1 50.371947-1.732998 33.647965 33.647965 0 0 1 11.165988 25.186973 35.544963 35.544963 0 0 1-9.98399 24.575974v-0.04z m0 0" fill="#52C41A" p-id="5065"></path></svg></i>${text}
|
||||||
`
|
`
|
||||||
|
} else if (type == 'warning') {
|
||||||
|
message.innerHTML = `
|
||||||
|
<i><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1756093599258" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1648" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M512.002558 64.24521c-247.292176 0-447.75786 200.464661-447.75786 447.756837 0 247.287059 200.464661 447.752744 447.75786 447.752744 247.286036 0 447.75172-200.464661 447.75172-447.752744C959.754279 264.710894 759.288594 64.24521 512.002558 64.24521zM512.010745 735.87586c-20.602224 0-37.319977-16.718777-37.319977-37.323047 0-20.597107 16.717753-37.319977 37.319977-37.319977 20.60427 0 37.297464 16.72287 37.297464 37.319977C549.308209 719.158107 532.613992 735.87586 512.010745 735.87586zM549.308209 567.969733c0 20.600177-16.693194 37.293371-37.297464 37.293371-20.602224 0-37.319977-16.693194-37.319977-37.293371L474.690768 325.420581c0-20.605294 16.717753-37.297464 37.319977-37.297464 20.60427 0 37.297464 16.693194 37.297464 37.297464L549.308209 567.969733z" fill="#e98f36" p-id="1649"></path></svg></i>${text}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
document.body.appendChild(message)
|
document.body.appendChild(message)
|
||||||
message.classList.add(type)
|
message.classList.add(type)
|
||||||
}
|
}
|
||||||
|
@ -3799,6 +3799,10 @@
|
|||||||
background-color: #f0f9eb;
|
background-color: #f0f9eb;
|
||||||
color: rgb(82, 196, 26);
|
color: rgb(82, 196, 26);
|
||||||
}
|
}
|
||||||
|
#YJ-custom-message.warning {
|
||||||
|
background-color: #fdf6ec;
|
||||||
|
color: #e6a23c;
|
||||||
|
}
|
||||||
|
|
||||||
/* 滑入动画 */
|
/* 滑入动画 */
|
||||||
@keyframes YJ-custom-message-slideDown {
|
@keyframes YJ-custom-message-slideDown {
|
||||||
@ -3815,4 +3819,4 @@
|
|||||||
top: -200px
|
top: -200px
|
||||||
/* 移回顶部外 */
|
/* 移回顶部外 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user