2025-07-03 13:54:01 +08:00
|
|
|
|
/**
|
|
|
|
|
* 多边形
|
|
|
|
|
*/
|
|
|
|
|
import Dialog from '../../Element/Dialog';
|
|
|
|
|
import cy_tabs from "../../Element/cy_html_tabs";
|
|
|
|
|
import richText from "../../Element/richText";
|
|
|
|
|
import { html } from "./_element";
|
|
|
|
|
import Base from "../../Base/index";
|
|
|
|
|
import LabelObject from '../../Base/LabelObject'
|
|
|
|
|
import MouseEvent from '../../../Event/index'
|
|
|
|
|
import MouseTip from '../../../MouseTip'
|
|
|
|
|
import { syncData } from '../../../Global/MultiViewportMode'
|
|
|
|
|
import TestMaterialProperty from "./TestMaterialProperty";
|
|
|
|
|
import { legp } from '../../Element/datalist';
|
|
|
|
|
// import EditParticle from "../../ModelController/EditParticle";
|
|
|
|
|
|
|
|
|
|
class PolygonObject extends Base {
|
|
|
|
|
/**
|
|
|
|
|
* @constructor
|
|
|
|
|
* @param sdk
|
|
|
|
|
* @description 多边形
|
|
|
|
|
* @param options {object} 属性
|
|
|
|
|
* @param options.id {string} 唯一标识
|
|
|
|
|
* @param options.show=true {boolean} 显示/隐藏
|
|
|
|
|
* @param options.name {string} 名称
|
|
|
|
|
* @param options.color="#36c4ff" {string} 颜色
|
|
|
|
|
* @param options.height {number} 高度
|
|
|
|
|
* @param options.ground=true {boolean} 是否贴地
|
|
|
|
|
* @param options.line {object} 边框
|
|
|
|
|
* @param options.line.width=2 {string} 边框宽
|
|
|
|
|
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
|
|
|
|
* @param {Array.<object>} options.positions 经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
|
|
|
|
|
|
|
|
|
* @param _Dialog {object} 弹框事件
|
|
|
|
|
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
|
|
|
|
* */
|
|
|
|
|
constructor(sdk, options = {}, _Dialog = {}) {
|
|
|
|
|
super(sdk, options);
|
|
|
|
|
this.options.name = options.name || '未命名对象'
|
|
|
|
|
this.options.color = options.color || "#36c4ff"
|
|
|
|
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
|
|
|
|
this.options.height = options.height
|
|
|
|
|
this.options.ground = (options.ground || options.ground === false) ? options.ground : true
|
|
|
|
|
this.options.positions = options.positions || []
|
|
|
|
|
this.options.line = options.line || {}
|
|
|
|
|
this.options.line.width = this.options.line.width || 2
|
|
|
|
|
this.options.line.color = this.options.line.color || 'rgba(155, 155, 124, 0.89)'
|
|
|
|
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
|
|
|
|
this.entity
|
|
|
|
|
this.event = new MouseEvent(this.sdk)
|
|
|
|
|
this.operate = {}
|
|
|
|
|
this._elms = {};
|
|
|
|
|
this.Dialog = _Dialog
|
|
|
|
|
this.nodePoints = []
|
|
|
|
|
options.label = options.label || {}
|
|
|
|
|
this.options.label = {
|
|
|
|
|
text: this.options.name,
|
|
|
|
|
show: options.label.show || false,
|
|
|
|
|
position: options.label.position,
|
|
|
|
|
fontSize: (options.label.fontSize || options.label.fontSize === 0) ? options.label.fontSize : 20,
|
|
|
|
|
color: options.label.color || '#ffffff',
|
|
|
|
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
|
|
|
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
|
|
|
|
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
2025-07-09 11:15:53 +08:00
|
|
|
|
lineColor: options.label.lineColor || '#00ffff80',
|
2025-07-03 13:54:01 +08:00
|
|
|
|
scaleByDistance: options.label.scaleByDistance || false,
|
|
|
|
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
|
|
|
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
|
|
|
|
}
|
|
|
|
|
this.options.attribute = options.attribute || {}
|
|
|
|
|
this.options.attribute.link = this.options.attribute.link || {}
|
|
|
|
|
this.options.attribute.link.content = this.options.attribute.link.content || []
|
|
|
|
|
this.options.attribute.camera = this.options.attribute.camera || {}
|
|
|
|
|
this.options.attribute.camera.content = this.options.attribute.camera.content || []
|
|
|
|
|
this.options.attribute.vr = this.options.attribute.vr || {}
|
|
|
|
|
this.options.attribute.vr.content = this.options.attribute.vr.content || []
|
|
|
|
|
this.options.attribute.goods = this.options.attribute.goods || {}
|
|
|
|
|
this.options.attribute.goods.content = this.options.attribute.goods.content || []
|
|
|
|
|
this.options.attributeType = options.attributeType || 'richText'
|
|
|
|
|
if (!this.options.positions || this.options.positions.length < 3) {
|
|
|
|
|
this._error = '多边形最少需要三个坐标!'
|
|
|
|
|
console.warn(this._error)
|
|
|
|
|
window.ELEMENT && window.ELEMENT.Message({
|
|
|
|
|
message: this._error,
|
|
|
|
|
type: 'warning',
|
|
|
|
|
duration: 1500
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.sdk.addIncetance(this.options.id, this)
|
|
|
|
|
this._zIndex = this.sdk.entityMap.size
|
|
|
|
|
PolygonObject.create(this)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get type() {
|
|
|
|
|
return 'PolygonObject'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get color() {
|
|
|
|
|
return this.options.color
|
|
|
|
|
}
|
|
|
|
|
set color(v) {
|
|
|
|
|
this.options.color = v
|
|
|
|
|
this.entity.polygon.material = Cesium.Color.fromCssColorString(v)
|
|
|
|
|
if (this._elms.color) {
|
|
|
|
|
this._elms.color.forEach((item, i) => {
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let colorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: item.el,
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: v,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (c) => {
|
|
|
|
|
this.color = c
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.color = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
|
|
|
|
this._elms.color[i] = colorPicker
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get height() {
|
|
|
|
|
return this.options.height
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set height(v) {
|
|
|
|
|
this.options.height = v
|
|
|
|
|
if (!this.options.height) {
|
|
|
|
|
this.options.height = 0
|
|
|
|
|
}
|
|
|
|
|
let positions = this.options.positions
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, this.options.height)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
this.entity.polygon.hierarchy = new Cesium.PolygonHierarchy(this.positions)
|
|
|
|
|
this.entity.polygon.perPositionHeight = (!this.ground) ? true : false
|
|
|
|
|
this.entity.polyline.positions = [...this.positions, this.positions[0], this.positions[1]]
|
|
|
|
|
this.entity.polyline.clampToGround = (!this.ground) ? false : true
|
|
|
|
|
|
|
|
|
|
this._elms.height && this._elms.height.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get ground() {
|
|
|
|
|
return this.options.ground
|
|
|
|
|
}
|
|
|
|
|
set ground(v) {
|
|
|
|
|
if (typeof v === "boolean") {
|
|
|
|
|
this.options.ground = v
|
|
|
|
|
let positions = this.options.positions
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (!v) {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, this.options.height)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
this.entity.polygon.hierarchy = new Cesium.PolygonHierarchy(this.positions)
|
|
|
|
|
this.entity.polygon.perPositionHeight = (!this.ground) ? true : false
|
|
|
|
|
this.entity.polyline.positions = [...this.positions, this.positions[0], this.positions[1]]
|
|
|
|
|
this.entity.polyline.clampToGround = (!this.ground) ? false : true
|
|
|
|
|
|
|
|
|
|
let positions2 = [[]]
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
positions2[0].push([positions[i].lng, positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions2[0].push([positions[0].lng, positions[0].lat])
|
|
|
|
|
let polygon = turf.polygon(positions2);
|
|
|
|
|
let centroid = turf.centroid(polygon);
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
this.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], this.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }).then((height) => {
|
|
|
|
|
this.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height]
|
|
|
|
|
})
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
this._elms.ground && this._elms.ground.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
console.error("参数必须为boolean")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get lineColor() {
|
|
|
|
|
return this.options.line.color
|
|
|
|
|
}
|
|
|
|
|
set lineColor(v) {
|
|
|
|
|
this.options.line.color = v
|
|
|
|
|
if(!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
|
|
|
|
if (this._elms.lineColor) {
|
|
|
|
|
this._elms.lineColor.forEach((item, i) => {
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let lineColorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: item.el,
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: v,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (c) => {
|
|
|
|
|
this.lineColor = c
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.lineColor = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
|
|
|
|
this._elms.lineColor[i] = lineColorPicker
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get lineWidth() {
|
|
|
|
|
return this.options.line.width
|
|
|
|
|
}
|
|
|
|
|
set lineWidth(v) {
|
|
|
|
|
this.options.line.width = v
|
|
|
|
|
this.entity.polyline.width = v
|
|
|
|
|
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get area() {
|
|
|
|
|
return this.options.area
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set area(v) {
|
|
|
|
|
this.options.area = v
|
|
|
|
|
this._elms.area && this._elms.area.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get areaUnit() {
|
|
|
|
|
return this.options['area-unit']
|
|
|
|
|
}
|
|
|
|
|
set areaUnit(v) {
|
|
|
|
|
this.options['area-unit'] = v
|
|
|
|
|
this._elms.areaUnit && this._elms.areaUnit.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
if (this.options.areaByMeter) {
|
|
|
|
|
switch (v) {
|
|
|
|
|
case '平方米':
|
|
|
|
|
this.area = this.options.areaByMeter
|
|
|
|
|
break;
|
|
|
|
|
case '平方千米':
|
|
|
|
|
this.area = Number((this.options.areaByMeter / 1000000).toFixed(8))
|
|
|
|
|
break;
|
|
|
|
|
case '亩':
|
|
|
|
|
this.area = Number((this.options.areaByMeter / 666.6666667).toFixed(4))
|
|
|
|
|
break;
|
|
|
|
|
case '公顷':
|
|
|
|
|
this.area = Number((this.options.areaByMeter / 10000).toFixed(6))
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
this.area = this.options.areaByMeter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelShow() {
|
|
|
|
|
return this.options.label.show
|
|
|
|
|
}
|
|
|
|
|
set labelShow(v) {
|
|
|
|
|
this.options.label.show = v
|
2025-08-22 21:55:50 +08:00
|
|
|
|
if (this.show && !this.showView || this.showView == 3) {
|
2025-07-03 13:54:01 +08:00
|
|
|
|
this.label.show = v
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.label.show = false
|
|
|
|
|
}
|
|
|
|
|
this._elms.labelShow && this._elms.labelShow.forEach((item) => {
|
|
|
|
|
item.checked = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelColor() {
|
|
|
|
|
return this.options.label.color
|
|
|
|
|
}
|
|
|
|
|
set labelColor(v) {
|
|
|
|
|
this.options.label.color = v
|
|
|
|
|
this.label.color = v
|
|
|
|
|
if (this._elms.labelColor) {
|
|
|
|
|
this._elms.labelColor.forEach((item, i) => {
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let labelColorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: item.el,
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.labelColor,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelColor = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelColor = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
|
|
|
|
this._elms.labelColor[i] = labelColorPicker
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelFontSize() {
|
|
|
|
|
return this.options.label.fontSize
|
|
|
|
|
}
|
|
|
|
|
set labelFontSize(v) {
|
|
|
|
|
this.options.label.fontSize = v
|
|
|
|
|
this.label.fontSize = v
|
|
|
|
|
this._elms.labelFontSize && this._elms.labelFontSize.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelScaleByDistance() {
|
|
|
|
|
return this.options.label.scaleByDistance
|
|
|
|
|
}
|
|
|
|
|
set labelScaleByDistance(v) {
|
|
|
|
|
this.options.label.scaleByDistance = v
|
|
|
|
|
this.label.scaleByDistance = v
|
|
|
|
|
this._elms.labelScaleByDistance && this._elms.labelScaleByDistance.forEach((item) => {
|
|
|
|
|
item.checked = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelNear() {
|
|
|
|
|
return this.options.label.near
|
|
|
|
|
}
|
|
|
|
|
set labelNear(v) {
|
|
|
|
|
let near = v
|
|
|
|
|
if (near > this.labelFar) {
|
|
|
|
|
near = this.labelFar
|
|
|
|
|
}
|
|
|
|
|
this.options.label.near = near
|
|
|
|
|
this.label.near = near
|
|
|
|
|
this._elms.labelNear && this._elms.labelNear.forEach((item) => {
|
|
|
|
|
item.value = near
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelFar() {
|
|
|
|
|
return this.options.label.far
|
|
|
|
|
}
|
|
|
|
|
set labelFar(v) {
|
|
|
|
|
let far = v
|
|
|
|
|
if (far < this.labelNear) {
|
|
|
|
|
far = this.labelNear
|
|
|
|
|
}
|
|
|
|
|
this.options.label.far = far
|
|
|
|
|
this.label.far = far
|
|
|
|
|
this._elms.labelFar && this._elms.labelFar.forEach((item) => {
|
|
|
|
|
item.value = far
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelLineWidth() {
|
|
|
|
|
return this.options.label.lineWidth
|
|
|
|
|
}
|
|
|
|
|
set labelLineWidth(v) {
|
|
|
|
|
this.options.label.lineWidth = v
|
|
|
|
|
this.label.lineWidth = v
|
|
|
|
|
this._elms.labelLineWidth && this._elms.labelLineWidth.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelPixelOffset() {
|
|
|
|
|
return this.options.label.pixelOffset
|
|
|
|
|
}
|
|
|
|
|
set labelPixelOffset(v) {
|
|
|
|
|
this.options.label.pixelOffset = v
|
|
|
|
|
this.label.pixelOffset = v
|
|
|
|
|
this._elms.labelPixelOffset && this._elms.labelPixelOffset.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
get labelLineColor() {
|
|
|
|
|
return this.options.label.lineColor
|
|
|
|
|
}
|
|
|
|
|
set labelLineColor(v) {
|
|
|
|
|
this.options.label.lineColor = v
|
|
|
|
|
this.label.lineColor = v
|
|
|
|
|
if (this._elms.labelLineColor) {
|
|
|
|
|
this._elms.labelLineColor.forEach((item, i) => {
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let lineColorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: item.el,
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.labelLineColor,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelLineColor = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
|
|
|
|
this._elms.labelLineColor[i] = lineColorPicker
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get labelBackgroundColorStart() {
|
|
|
|
|
return this.options.label.backgroundColor[0]
|
|
|
|
|
}
|
|
|
|
|
set labelBackgroundColorStart(v) {
|
|
|
|
|
this.options.label.backgroundColor[0] = v
|
|
|
|
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
|
|
|
|
if (this._elms.labelBackgroundColorStart) {
|
|
|
|
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: item.el,
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.labelBackgroundColorStart,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelBackgroundColorStart = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
|
|
|
|
this._elms.labelBackgroundColorStart[i] = labelBackgroundColorStartPicker
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
get labelBackgroundColorEnd() {
|
|
|
|
|
return this.options.label.backgroundColor[1]
|
|
|
|
|
}
|
|
|
|
|
set labelBackgroundColorEnd(v) {
|
|
|
|
|
this.options.label.backgroundColor[1] = v
|
|
|
|
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
|
|
|
|
if (this._elms.labelBackgroundColorEnd) {
|
|
|
|
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: item.el,
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.labelBackgroundColorEnd,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelBackgroundColorEnd = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelBackgroundColorEnd = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
|
|
|
|
this._elms.labelBackgroundColorEnd[i] = labelBackgroundColorEndPicker
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get attributeType() {
|
|
|
|
|
return this.options.attributeType
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set attributeType(v) {
|
|
|
|
|
this.options.attributeType = v
|
|
|
|
|
this._elms.attributeType && this._elms.attributeType.forEach((item) => {
|
|
|
|
|
item.value = v
|
|
|
|
|
})
|
|
|
|
|
let attributeContent = this._DialogObject._element.content.getElementsByClassName('attribute-content')
|
|
|
|
|
for (let i = 0; i < attributeContent.length; i++) {
|
|
|
|
|
if (attributeContent[i].className.indexOf('attribute-content-' + v) > -1) {
|
|
|
|
|
attributeContent[i].style.display = 'block';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
attributeContent[i].style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get attributeLink() {
|
|
|
|
|
return this.options.attribute.link.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set attributeLink(v) {
|
|
|
|
|
this.options.attribute.link.content = v
|
|
|
|
|
if (!this._DialogObject || !this._DialogObject._element || !this._DialogObject._element.content || this._DialogObject._element.content.getElementsByClassName('attribute-content-link').length == 0) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-link')[1].getElementsByClassName('table')[0]
|
|
|
|
|
let tableContent = table.getElementsByClassName('table-body')[0]
|
|
|
|
|
tableContent.innerHTML = ''
|
|
|
|
|
if (this.options.attribute.link.content.length > 0) {
|
|
|
|
|
table.getElementsByClassName('table-empty')[0].style.display = 'none'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
table.getElementsByClassName('table-empty')[0].style.display = 'flex'
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < this.options.attribute.link.content.length; i++) {
|
|
|
|
|
let tr = `
|
|
|
|
|
<div class="tr">
|
|
|
|
|
<div class="td center">` + this.options.attribute.link.content[i].name + `</div>
|
|
|
|
|
<div class="td center">` + this.options.attribute.link.content[i].url + `</div>
|
|
|
|
|
<div class="td center">
|
|
|
|
|
<button style="margin-right: 5px;" @click="linkEdit">编辑</button>
|
|
|
|
|
<button @click="linkDelete">删除</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`
|
|
|
|
|
let trElm = document.createRange().createContextualFragment(tr)
|
|
|
|
|
tableContent.appendChild(trElm)
|
|
|
|
|
}
|
|
|
|
|
let item = tableContent.getElementsByClassName('tr')
|
|
|
|
|
let fun = {
|
|
|
|
|
linkEdit: async (index) => {
|
|
|
|
|
this.attributeLink = await this.options.attribute.link.content
|
|
|
|
|
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-link')[1].getElementsByClassName('table')[0]
|
|
|
|
|
let tableContent = table.getElementsByClassName('table-body')[0]
|
|
|
|
|
let item = tableContent.getElementsByClassName('tr')
|
|
|
|
|
for (let i = 0; i < item.length; i++) {
|
|
|
|
|
if (index === i) {
|
|
|
|
|
let height = item[i].offsetHeight
|
|
|
|
|
let html = `
|
|
|
|
|
<div class="td">
|
|
|
|
|
<input class="input" type="text">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="td">
|
|
|
|
|
<textarea class="input link-edit" type="text"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="td center">
|
|
|
|
|
<button style="margin-right: 5px;" @click="confirmEdit">确认</button>
|
|
|
|
|
<button @click="cancelEdit">取消</button>
|
|
|
|
|
</div>`
|
|
|
|
|
item[i].innerHTML = html
|
|
|
|
|
let textareaElm = item[i].getElementsByClassName('link-edit')[0]
|
|
|
|
|
textareaElm.style.height = (height - 10) + 'px'
|
|
|
|
|
let td = item[i].getElementsByClassName('td')
|
|
|
|
|
td[0].getElementsByClassName('input')[0].value = this.options.attribute.link.content[index].name
|
|
|
|
|
td[1].getElementsByClassName('input')[0].value = this.options.attribute.link.content[index].url
|
|
|
|
|
let btn = item[i].getElementsByTagName('button')
|
|
|
|
|
for (let n = 0; n < btn.length; n++) {
|
|
|
|
|
if (!btn[n] || !btn[n].attributes) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for (let m of btn[n].attributes) {
|
|
|
|
|
if (m.name === '@click') {
|
|
|
|
|
btn[n].addEventListener('click', (e) => {
|
|
|
|
|
if (typeof (fun[m.value]) === 'function') {
|
|
|
|
|
fun[m.value]({ name: td[0].getElementsByClassName('input')[0].value, url: td[1].getElementsByClassName('input')[0].value }, i)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btn[n].attributes.removeNamedItem(m.name)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
linkDelete: (i) => {
|
|
|
|
|
this.options.attribute.link.content.splice(i, 1)
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
confirmEdit: (value, i) => {
|
|
|
|
|
let name = value.name && value.name.replace(/\s/g, "")
|
|
|
|
|
let url = value.url && value.url.replace(/\s/g, "")
|
|
|
|
|
if (name && url) {
|
|
|
|
|
this.options.attribute.link.content[i] = value
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
window.ELEMENT && window.ELEMENT.Message({
|
|
|
|
|
message: '名称或链接不能为空!',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
duration: 1500
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
},
|
|
|
|
|
cancelEdit: () => {
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
},
|
|
|
|
|
fileSelect: (value, i) => {
|
|
|
|
|
let fileElm = item[i].getElementsByClassName('file-select')[0]
|
|
|
|
|
fileElm.click()
|
|
|
|
|
fileElm.removeEventListener('change', fileSelect)
|
|
|
|
|
fileElm.addEventListener('change', fileSelect)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let fileSelect = (event) => {
|
|
|
|
|
if (event.target.value) {
|
|
|
|
|
let td = item[event.target.getAttribute('index')].getElementsByClassName('td')
|
|
|
|
|
td[1].getElementsByClassName('input')[0].value = event.target.value
|
|
|
|
|
event.target.value = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < item.length; i++) {
|
|
|
|
|
let btn = item[i].getElementsByTagName('button')
|
|
|
|
|
for (let n = 0; n < btn.length; n++) {
|
|
|
|
|
if (!btn[n] ||!btn[n].attributes) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for (let m of btn[n].attributes) {
|
|
|
|
|
if (m.name === '@click') {
|
|
|
|
|
btn[n].addEventListener('click', (e) => {
|
|
|
|
|
if (typeof (fun[m.value]) === 'function') {
|
|
|
|
|
fun[m.value](i)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btn[n].attributes.removeNamedItem(m.name)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get attributeCamera() {
|
|
|
|
|
return this.options.attribute.camera.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set attributeCamera(v) {
|
|
|
|
|
this.options.attribute.camera.content = v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get attributeVr() {
|
|
|
|
|
return this.options.attribute.vr.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set attributeVr(v) {
|
|
|
|
|
this.options.attribute.vr.content = v
|
|
|
|
|
if (!this._DialogObject || !this._DialogObject._element || !this._DialogObject._element.content || this._DialogObject._element.content.getElementsByClassName('attribute-content-vr').length == 0) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-vr')[1].getElementsByClassName('table')[0]
|
|
|
|
|
let tableContent = table.getElementsByClassName('table-body')[0]
|
|
|
|
|
tableContent.innerHTML = ''
|
|
|
|
|
if (this.options.attribute.vr.content.length > 0) {
|
|
|
|
|
table.getElementsByClassName('table-empty')[0].style.display = 'none'
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
table.getElementsByClassName('table-empty')[0].style.display = 'flex'
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < this.options.attribute.vr.content.length; i++) {
|
|
|
|
|
let tr = `
|
|
|
|
|
<div class="tr">
|
|
|
|
|
<div class="td">` + this.options.attribute.vr.content[i].name + `</div>
|
|
|
|
|
<div class="td">` + this.options.attribute.vr.content[i].url + `</div>
|
|
|
|
|
<div class="td">
|
|
|
|
|
<button @click="vrEdit">编辑</button>
|
|
|
|
|
<button @click="vrDelete">删除</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`
|
|
|
|
|
let trElm = document.createRange().createContextualFragment(tr)
|
|
|
|
|
tableContent.appendChild(trElm)
|
|
|
|
|
}
|
|
|
|
|
let item = tableContent.getElementsByClassName('tr')
|
|
|
|
|
let fun = {
|
|
|
|
|
vrEdit: async (index) => {
|
|
|
|
|
this.attributeVr = await this.options.attribute.vr.content
|
|
|
|
|
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-vr')[1].getElementsByClassName('table')[0]
|
|
|
|
|
let tableContent = table.getElementsByClassName('table-body')[0]
|
|
|
|
|
let item = tableContent.getElementsByClassName('tr')
|
|
|
|
|
for (let i = 0; i < item.length; i++) {
|
|
|
|
|
if (index === i) {
|
|
|
|
|
let height = item[i].offsetHeight
|
|
|
|
|
let html = `
|
|
|
|
|
<div class="td">
|
|
|
|
|
<input class="input" type="text">
|
|
|
|
|
</div>
|
|
|
|
|
<div class="td">
|
|
|
|
|
<textarea class="input link-edit" type="text"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="td">
|
|
|
|
|
<button @click="confirmEdit">确认</button>
|
|
|
|
|
<button @click="cancelEdit">取消</button>
|
|
|
|
|
</div>`
|
|
|
|
|
item[i].innerHTML = html
|
|
|
|
|
let textareaElm = item[i].getElementsByClassName('link-edit')[0]
|
|
|
|
|
textareaElm.style.height = (height - 10) + 'px'
|
|
|
|
|
let td = item[i].getElementsByClassName('td')
|
|
|
|
|
td[0].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].name
|
|
|
|
|
td[1].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].url
|
|
|
|
|
let btn = item[i].getElementsByTagName('button')
|
|
|
|
|
for (let n = 0; n < btn.length; n++) {
|
|
|
|
|
if (!btn[n] ||!btn[n].attributes) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for (let m of btn[n].attributes) {
|
|
|
|
|
if (m.name === '@click') {
|
|
|
|
|
btn[n].addEventListener('click', (e) => {
|
|
|
|
|
if (typeof (fun[m.value]) === 'function') {
|
|
|
|
|
fun[m.value]({ name: td[0].getElementsByClassName('input')[0].value, url: td[1].getElementsByClassName('input')[0].value }, i)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btn[n].attributes.removeNamedItem(m.name)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
vrDelete: (i) => {
|
|
|
|
|
this.options.attribute.vr.content.splice(i, 1)
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
confirmEdit: (value, i) => {
|
|
|
|
|
let name = value.name && value.name.replace(/\s/g, "")
|
|
|
|
|
let url = value.url && value.url.replace(/\s/g, "")
|
|
|
|
|
if (name && url) {
|
|
|
|
|
this.options.attribute.vr.content[i] = value
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
window.ELEMENT && window.ELEMENT.Message({
|
|
|
|
|
message: '名称或链接不能为空!',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
duration: 1500
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
},
|
|
|
|
|
cancelEdit: () => {
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
},
|
|
|
|
|
fileSelect: (value, i) => {
|
|
|
|
|
let fileElm = item[i].getElementsByClassName('file-select')[0]
|
|
|
|
|
fileElm.click()
|
|
|
|
|
fileElm.removeEventListener('change', fileSelect)
|
|
|
|
|
fileElm.addEventListener('change', fileSelect)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let fileSelect = (event) => {
|
|
|
|
|
if (event.target.value) {
|
|
|
|
|
let td = item[event.target.getAttribute('index')].getElementsByClassName('td')
|
|
|
|
|
td[1].getElementsByClassName('input')[0].value = event.target.value
|
|
|
|
|
event.target.value = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < item.length; i++) {
|
|
|
|
|
let btn = item[i].getElementsByTagName('button')
|
|
|
|
|
for (let n = 0; n < btn.length; n++) {
|
|
|
|
|
if (!btn[n] ||!btn[n].attributes) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for (let m of btn[n].attributes) {
|
|
|
|
|
if (m.name === '@click') {
|
|
|
|
|
btn[n].addEventListener('click', (e) => {
|
|
|
|
|
if (typeof (fun[m.value]) === 'function') {
|
|
|
|
|
fun[m.value](i)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btn[n].attributes.removeNamedItem(m.name)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get attributeGoods() {
|
|
|
|
|
return this.options.attribute.goods.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set attributeGoods(v) {
|
|
|
|
|
this.options.attribute.goods.content = v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static create(that) {
|
|
|
|
|
let positions = that.options.positions
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, that.options.height)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
|
|
|
|
|
const video = document.getElementsByTagName('video')[0];
|
|
|
|
|
console.log('that.options.rotation', that.options.rotation)
|
|
|
|
|
|
|
|
|
|
let polygon = new Cesium.PolygonGeometry({
|
|
|
|
|
polygonHierarchy: new Cesium.PolygonHierarchy(
|
|
|
|
|
Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
)
|
|
|
|
|
});
|
|
|
|
|
let texture = new Cesium.Texture({
|
|
|
|
|
context: that.sdk.viewer.scene.context,
|
|
|
|
|
source: video
|
|
|
|
|
})
|
|
|
|
|
console.log('texture', texture)
|
|
|
|
|
let appearance = new Cesium.EllipsoidSurfaceAppearance({
|
|
|
|
|
// aboveGroud: true,
|
|
|
|
|
translucent: true, //false时透明度无效
|
|
|
|
|
closed: false,
|
|
|
|
|
material: new Cesium.Material({
|
|
|
|
|
fabric: {
|
|
|
|
|
type: "Image",
|
|
|
|
|
uniforms: {
|
|
|
|
|
colorTexture: "data:image/jpg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEAAQBIAAAAAQAB/+Ekcmh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8APD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQ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JMZXNxU2NCc29IZW1OSnRPZitjZFk0NC9LbXN4eHFGUmRabUNxTmdCOVYmI3hBO3RzUWd2VmNLSFlxN0ZYWXE3RlhZcThRLzV5Ny9BUEpiYWIvMjJZUCtvVzV3RmxGODNlUi95eTg0ZWVQcnYrSExSTHI5SCtsOWE1eXgmI3hBO3hjZlg1OEtlb3kxcjZUZE1ESWxsWC9RczM1d2Y5V3FIL3BMdHYrYThhUmJ2K2hadnpnLzZ0VVAvQUVsMjMvTmVOTGJ2K2hadnpnLzYmI3hBO3RVUC9BRWwyMy9OZU5MYnYraFp2emcvNnRVU
|
|
|
|
|
},
|
|
|
|
|
source: `
|
|
|
|
|
uniform vec2 repeat;
|
|
|
|
|
uniform sampler2D image;
|
|
|
|
|
uniform vec4 color;
|
|
|
|
|
uniform sampler2D colorTexture;
|
|
|
|
|
czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
|
|
|
{
|
|
|
|
|
czm_material material = czm_getDefaultMaterial(materialInput);
|
|
|
|
|
material.diffuse = czm_gammaCorrect(texture2D(image, fract(repeat * materialInput.st)).rgb * color.rgb);
|
|
|
|
|
material.alpha = texture2D(image, fract(repeat * materialInput.st)).a * color.a;
|
|
|
|
|
return material;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
console.log('polygon', polygon)
|
|
|
|
|
let polygonPrimitive = new Cesium.Primitive({
|
|
|
|
|
geometryInstances: [new Cesium.GeometryInstance({
|
|
|
|
|
geometry: polygon,
|
|
|
|
|
attributes: {
|
|
|
|
|
color: Cesium.ColorGeometryInstanceAttribute.fromColor(
|
|
|
|
|
Cesium.Color.fromCssColorString('rgb(255, 235, 59, 0.4)')
|
|
|
|
|
),
|
|
|
|
|
show: new Cesium.ShowGeometryInstanceAttribute(true),
|
|
|
|
|
}
|
|
|
|
|
})],
|
|
|
|
|
appearance: appearance,
|
|
|
|
|
});
|
|
|
|
|
console.log('polygonPrimitive', polygonPrimitive)
|
|
|
|
|
that.sdk.viewer.scene.primitives.add(polygonPrimitive);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// that.entity = that.sdk.viewer.entities.add({
|
|
|
|
|
// show: that.options.show,
|
|
|
|
|
// // id: that.options.id,
|
|
|
|
|
// polygon: {
|
|
|
|
|
// hierarchy: new Cesium.PolygonHierarchy(that.positions),
|
|
|
|
|
// perPositionHeight: true,
|
|
|
|
|
// material: new TestMaterialProperty({
|
|
|
|
|
// image: video,
|
|
|
|
|
// repeat: new Cesium.Cartesian2(1.0, 1.0),
|
|
|
|
|
// color: Cesium.Color.TOMATO,
|
|
|
|
|
// rotate: 0,
|
|
|
|
|
// tmask: "data:image/jpg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEAAQBIAAAAAQAB/+Ekcmh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8APD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgICAgICAgICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgICAgICAgICAgeG1sbnM6eG1wR0ltZz0iaHR0cDovL25zLmFkb2JlLmNv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ESWxsWC9RczM1d2Y5V3FIL3BMdHYrYThhUmJ2K2hadnpnLzZ0VVAvQUVsMjMvTmVOTGJ2K2hadnpnLzYmI3hBO3RVUC9BRWwyMy9OZU5MYnYraFp2emcvNnRV
|
|
|
|
|
// }),
|
|
|
|
|
// stRotation: Cesium.Math.toRadians(that.options.rotation),
|
|
|
|
|
// zIndex: that.sdk._entityZIndex
|
|
|
|
|
// },
|
|
|
|
|
// polyline: {
|
|
|
|
|
// positions: [...that.positions, that.positions[0], that.positions[1]],
|
|
|
|
|
// width: that.options.line.width,
|
|
|
|
|
// material: Cesium.Color.fromCssColorString(that.options.line.color),
|
|
|
|
|
// clampToGround: (!that.ground) ? false : true,
|
|
|
|
|
// zIndex: that.sdk._entityZIndex
|
|
|
|
|
// },
|
|
|
|
|
// })
|
|
|
|
|
that.sdk._entityZIndex++
|
|
|
|
|
PolygonObject.createLabel(that)
|
|
|
|
|
that.options.areaByMeter = that.computeArea(positions);
|
|
|
|
|
switch (that.options['area-unit']) {
|
|
|
|
|
case '平方米':
|
|
|
|
|
that.options.area = that.options.areaByMeter
|
|
|
|
|
break;
|
|
|
|
|
case '平方千米':
|
|
|
|
|
that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
|
|
|
break;
|
|
|
|
|
case '亩':
|
|
|
|
|
that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
|
|
|
break;
|
|
|
|
|
case '公顷':
|
|
|
|
|
that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
that.options.area = that.options.areaByMeter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
syncData(that.sdk, that.options.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async createLabel(that) {
|
|
|
|
|
let positions = [[]]
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
positions[0].push([that.options.positions[i].lng, that.options.positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions[0].push([that.options.positions[0].lng, that.options.positions[0].lat])
|
|
|
|
|
let polygon = turf.polygon(positions);
|
|
|
|
|
// let centroid = turf.centroid(polygon);
|
|
|
|
|
let centroid = turf.pointOnFeature(polygon);
|
|
|
|
|
let height
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
height = that.options.height
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
height = await that.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] })
|
|
|
|
|
}
|
|
|
|
|
if (!that.options.label.position) {
|
|
|
|
|
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: height }
|
|
|
|
|
}
|
|
|
|
|
// 标签
|
|
|
|
|
that.label = new LabelObject(that.sdk, {
|
|
|
|
|
id: that.options.id,
|
|
|
|
|
show: that.options.show ? that.options.label.show : false,
|
|
|
|
|
position: [that.options.label.position.lng, that.options.label.position.lat, that.options.label.position.alt],
|
|
|
|
|
text: that.options.name,
|
|
|
|
|
fontSize: that.options.label.fontSize,
|
|
|
|
|
color: that.options.label.color,
|
|
|
|
|
pixelOffset: that.options.label.pixelOffset,
|
|
|
|
|
backgroundColor: that.options.label.backgroundColor,
|
|
|
|
|
lineColor: that.options.label.lineColor,
|
|
|
|
|
lineWidth: that.options.label.lineWidth,
|
|
|
|
|
scaleByDistance: that.options.label.scaleByDistance,
|
|
|
|
|
near: that.options.label.near,
|
|
|
|
|
far: that.options.label.far
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑框
|
|
|
|
|
async edit(state) {
|
|
|
|
|
let _this = this
|
|
|
|
|
this.originalOptions = this.deepCopyObj(this.options)
|
|
|
|
|
|
|
|
|
|
if (this._DialogObject && this._DialogObject.close) {
|
|
|
|
|
this._DialogObject.close()
|
|
|
|
|
this._DialogObject = null
|
|
|
|
|
}
|
|
|
|
|
if (state) {
|
|
|
|
|
this._DialogObject = await new Dialog(this.sdk, this.options, {
|
|
|
|
|
title: '编辑属性', left: '180px', top: '100px',
|
|
|
|
|
confirmCallBack: (options) => {
|
|
|
|
|
this.name = this.name.trim()
|
|
|
|
|
if (!this.name) {
|
|
|
|
|
this.name = '未命名对象'
|
|
|
|
|
}
|
|
|
|
|
this.options.label.position = { lng: this.label.position[0], lat: this.label.position[1], alt: this.label.position[2] }
|
|
|
|
|
this.originalOptions = this.deepCopyObj(this.options)
|
|
|
|
|
this._DialogObject.close()
|
|
|
|
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
|
|
|
|
syncData(this.sdk, this.options.id)
|
|
|
|
|
},
|
|
|
|
|
resetCallBack: () => {
|
|
|
|
|
this.reset()
|
|
|
|
|
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
|
|
|
|
},
|
|
|
|
|
removeCallBack: () => {
|
|
|
|
|
this.Dialog.removeCallBack && this.Dialog.removeCallBack()
|
|
|
|
|
},
|
|
|
|
|
closeCallBack: () => {
|
|
|
|
|
this.reset()
|
|
|
|
|
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
|
|
|
|
|
for (let i = 0; i < this.nodePoints.length; i++) {
|
|
|
|
|
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
|
|
|
|
}
|
|
|
|
|
this.nodePoints = []
|
|
|
|
|
YJ.Measure.SetMeasureStatus(false)
|
|
|
|
|
this.event && this.event.destroy()
|
|
|
|
|
this.tip && this.tip.destroy()
|
|
|
|
|
},
|
|
|
|
|
showCallBack: (show) => {
|
|
|
|
|
this.options.show = show
|
|
|
|
|
this.originalOptions.show = show
|
|
|
|
|
this.show = show
|
|
|
|
|
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
|
|
|
|
},
|
|
|
|
|
translationalCallBack: () => {
|
|
|
|
|
this.positionEditing = !this.positionEditing
|
|
|
|
|
},
|
|
|
|
|
// 二次编辑回调
|
|
|
|
|
secondaryEditCallBack: () => {
|
|
|
|
|
PolygonObject.nodeEdit(this)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' polygon'
|
|
|
|
|
let contentElm = document.createElement('div');
|
|
|
|
|
contentElm.innerHTML = html(this)
|
|
|
|
|
this._DialogObject.contentAppChild(contentElm)
|
|
|
|
|
this.attributeType = this.options.attributeType
|
|
|
|
|
this.attributeCamera = this.options.attribute.camera.content
|
|
|
|
|
|
|
|
|
|
// 创建标签页
|
|
|
|
|
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
|
|
|
|
// 颜色组件
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let colorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: contentElm.getElementsByClassName("color")[0],
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.color,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.color = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.color = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let linecolorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.lineColor,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.lineColor = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.lineColor = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let labelColorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.labelColor,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelColor = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelColor = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let lineColorPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
|
|
|
|
size: 'mini',//颜色box类型
|
|
|
|
|
alpha: true,//是否开启透明度
|
|
|
|
|
defaultColor: this.labelLineColor,
|
|
|
|
|
disabled: false,//是否禁止打开颜色选择器
|
|
|
|
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelLineColor = color
|
|
|
|
|
},//点击确认按钮事件回调
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
|
|
|
|
},//点击清空按钮事件回调
|
|
|
|
|
})
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
|
|
|
|
size: 'mini',
|
|
|
|
|
alpha: true,
|
|
|
|
|
defaultColor: this.labelBackgroundColorStart,
|
|
|
|
|
disabled: false,
|
|
|
|
|
openPickerAni: 'opacity',
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelBackgroundColorStart = color
|
|
|
|
|
},
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
|
|
|
|
},
|
|
|
|
|
})
|
2025-07-16 15:02:18 +08:00
|
|
|
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
2025-07-03 13:54:01 +08:00
|
|
|
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
|
|
|
|
size: 'mini',
|
|
|
|
|
alpha: true,
|
|
|
|
|
defaultColor: this.labelBackgroundColorEnd,
|
|
|
|
|
disabled: false,
|
|
|
|
|
openPickerAni: 'opacity',
|
|
|
|
|
sure: (color) => {
|
|
|
|
|
this.labelBackgroundColorEnd = color
|
|
|
|
|
},
|
|
|
|
|
clear: () => {
|
|
|
|
|
this.labelBackgroundColorEnd = 'rgba(255,255,255,1)'
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
let heightElm = this._DialogObject._element.body.getElementsByClassName('height')[0]
|
|
|
|
|
heightElm.value = this.height
|
|
|
|
|
heightElm.addEventListener('input', (e) => {
|
|
|
|
|
let value = e.target.value
|
|
|
|
|
if ((e.data === '.' && value.indexOf('.') === -1) || (e.data === '-' && value.indexOf('-') === -1)) {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (value) {
|
|
|
|
|
value = Number(value)
|
|
|
|
|
if ((e.target.max) && value > Number(e.target.max)) {
|
|
|
|
|
value = Number(e.target.max)
|
|
|
|
|
}
|
|
|
|
|
if ((e.target.min) && value < Number(e.target.min)) {
|
|
|
|
|
value = Number(e.target.min)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.height = value
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let all_elm = contentElm.getElementsByTagName("*")
|
|
|
|
|
PolygonObject.EventBinding(this, all_elm)
|
|
|
|
|
this._elms.height = [heightElm]
|
|
|
|
|
this._elms.color = [colorPicker]
|
|
|
|
|
this._elms.lineColor = [linecolorPicker]
|
|
|
|
|
this._elms.labelColor = [labelColorPicker]
|
|
|
|
|
this._elms.labelLineColor = [lineColorPicker]
|
|
|
|
|
this._elms.labelBackgroundColorStart = [labelBackgroundColorStartPicker]
|
|
|
|
|
this._elms.labelBackgroundColorEnd = [labelBackgroundColorEndPicker]
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
this.cameraSelect && this.cameraSelect()
|
|
|
|
|
this.goodsSelect && this.goodsSelect()
|
|
|
|
|
let tagData = this.attributeSelect
|
|
|
|
|
let attributeElm = this._DialogObject._element.content.getElementsByClassName('attribute-select-box')[0]
|
|
|
|
|
if (attributeElm) {
|
|
|
|
|
let legpObject = legp(attributeElm, ".attribute-select")
|
|
|
|
|
legpObject.legp_search(tagData)
|
|
|
|
|
let attributeSelectElm = this._DialogObject._element.content.getElementsByClassName('attribute-select')[0].getElementsByTagName('input')[0]
|
|
|
|
|
for (let i = 0; i < tagData.length; i++) {
|
|
|
|
|
if (tagData[i].key === this.options.attributeType) {
|
|
|
|
|
attributeSelectElm.value = tagData[i].value
|
|
|
|
|
legpObject.legp_searchActive(tagData[i].value)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
attributeSelectElm.addEventListener('input', () => {
|
|
|
|
|
for (let i = 0; i < tagData.length; i++) {
|
|
|
|
|
if (tagData[i].value === attributeSelectElm.value) {
|
|
|
|
|
this.attributeType = tagData[i].key
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let unitData = [{
|
|
|
|
|
name: '平方米',
|
|
|
|
|
value: '平方米'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '平方千米',
|
|
|
|
|
value: '平方千米'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '亩',
|
|
|
|
|
value: '亩'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '公顷',
|
|
|
|
|
value: '公顷'
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
let unitDataLegpObject = legp(this._DialogObject._element.content.getElementsByClassName('input-select-unit-box')[0], ".input-select-unit")
|
|
|
|
|
if (unitDataLegpObject) {
|
|
|
|
|
unitDataLegpObject.legp_search(unitData)
|
|
|
|
|
let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-select-unit')[0].getElementsByTagName('input')[0]
|
|
|
|
|
unitDataLegpElm.value = this.options['area-unit']
|
|
|
|
|
for (let i = 0; i < unitData.length; i++) {
|
|
|
|
|
if (unitData[i].value === unitDataLegpElm.value) {
|
|
|
|
|
unitDataLegpObject.legp_searchActive(unitData[i].value)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unitDataLegpElm.addEventListener('input', () => {
|
|
|
|
|
for (let i = 0; i < unitData.length; i++) {
|
|
|
|
|
if (unitData[i].value === unitDataLegpElm.value) {
|
|
|
|
|
this.areaUnit = unitData[i].value
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
|
} else {
|
|
|
|
|
if (this._DialogObject && this._DialogObject.remove) {
|
|
|
|
|
this._DialogObject.remove()
|
|
|
|
|
this._DialogObject = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
|
if (!this.entity && !this._DialogObject) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.options = this.deepCopyObj(this.originalOptions)
|
|
|
|
|
this.name = this.originalOptions.name
|
|
|
|
|
this.color = this.originalOptions.color
|
|
|
|
|
this.lineColor = this.originalOptions.line.color
|
|
|
|
|
this.lineWidth = this.originalOptions.line.width
|
|
|
|
|
this.area = this.originalOptions.area
|
|
|
|
|
this.height = this.originalOptions.height
|
|
|
|
|
this.ground = this.originalOptions.ground
|
|
|
|
|
this.areaUnit = this.originalOptions['area-unit']
|
|
|
|
|
this.labelShow = this.originalOptions.label.show
|
|
|
|
|
this.labelColor = this.originalOptions.label.color
|
|
|
|
|
this.labelFontSize = this.originalOptions.label.fontSize
|
|
|
|
|
this.labelFontFamily = this.originalOptions.label.fontFamily
|
|
|
|
|
this.labelScaleByDistance = this.originalOptions.label.scaleByDistance
|
|
|
|
|
this.labelNear = this.originalOptions.label.near
|
|
|
|
|
this.labelFar = this.originalOptions.label.far
|
|
|
|
|
this.labelLineWidth = this.originalOptions.label.lineWidth
|
|
|
|
|
this.labelPixelOffset = this.originalOptions.label.pixelOffset
|
|
|
|
|
this.labelLineColor = this.originalOptions.label.lineColor
|
|
|
|
|
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
|
|
|
|
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
this.attributeCamera = this.options.attribute.camera.content
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
this.attributeGoods = this.options.attribute.goods.content
|
|
|
|
|
this.cameraSelect && this.cameraSelect()
|
|
|
|
|
this.goodsSelect && this.goodsSelect()
|
|
|
|
|
|
|
|
|
|
let positions = this.options.positions
|
|
|
|
|
let positions2 = [[]]
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (this.options.height || this.options.height === 0) {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, this.options.height)
|
|
|
|
|
positions2[0].push([positions[i].lng, positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions2[0].push([positions[0].lng, positions[0].lat])
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
|
|
|
|
positions2[0].push([positions[i].lng, positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions2[0].push([positions[0].lng, positions[0].lat])
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
this.entity.polygon.hierarchy = new Cesium.PolygonHierarchy(this.positions)
|
|
|
|
|
this.entity.polyline.positions = [...this.positions, this.positions[0], this.positions[1]]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 飞到
|
|
|
|
|
*/
|
|
|
|
|
async flyTo(options = {}) {
|
|
|
|
|
if (this._error) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (this.options.customView) {
|
|
|
|
|
this.sdk.viewer.camera.flyTo({
|
|
|
|
|
destination: this.options.customView.position,
|
|
|
|
|
orientation: this.options.customView.orientation
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let positionArray = []
|
|
|
|
|
if ((!this.options.height && this.options.height !== 0) || this.ground) {
|
|
|
|
|
for (let i = 0; i < this.options.positions.length; i++) {
|
|
|
|
|
let height = await this.getClampToHeight(this.options.positions[i])
|
|
|
|
|
let a = Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat, height)
|
|
|
|
|
positionArray.push(a.x, a.y, a.z)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < this.options.positions.length; i++) {
|
|
|
|
|
let a = Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat, this.options.height)
|
|
|
|
|
positionArray.push(a.x, a.y, a.z)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray)
|
|
|
|
|
this.sdk.viewer.camera.flyToBoundingSphere(BoundingSphere, {
|
|
|
|
|
offset: options.orientation || {
|
|
|
|
|
heading: Cesium.Math.toRadians(0.0),
|
|
|
|
|
pitch: Cesium.Math.toRadians(-90.0),
|
|
|
|
|
roll: Cesium.Math.toRadians(0.0)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*/
|
|
|
|
|
async remove() {
|
|
|
|
|
this.event.destroy()
|
|
|
|
|
this.sdk.viewer.entities.remove(this.entity)
|
|
|
|
|
this.label.remove()
|
|
|
|
|
this.entity = null
|
|
|
|
|
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
|
|
|
|
this._DialogObject.close()
|
|
|
|
|
this._DialogObject = null
|
|
|
|
|
}
|
|
|
|
|
await this.sdk.removeIncetance(this.options.id)
|
|
|
|
|
await syncData(this.sdk, this.options.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addLink() {
|
|
|
|
|
// document.getElementsByClassName
|
|
|
|
|
if (this._DialogObject._element.content.getElementsByClassName('link_add')[0].value) {
|
|
|
|
|
this.options.attribute.link.content.push({
|
2025-07-03 15:54:39 +08:00
|
|
|
|
name: '链接',
|
2025-07-03 13:54:01 +08:00
|
|
|
|
url: this._DialogObject._element.content.getElementsByClassName('link_add')[0].value
|
|
|
|
|
})
|
|
|
|
|
this._DialogObject._element.content.getElementsByClassName('link_add')[0].value = ''
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.Dialog.clickAddLink && this.Dialog.clickAddLink()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addAttributeLink(link) {
|
|
|
|
|
this.options.attribute.link.content.push({
|
2025-07-03 15:54:39 +08:00
|
|
|
|
name: '链接',
|
2025-07-03 13:54:01 +08:00
|
|
|
|
url: link
|
|
|
|
|
})
|
|
|
|
|
this.attributeLink = this.options.attribute.link.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addRr() {
|
|
|
|
|
if (this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value) {
|
|
|
|
|
this.options.attribute.vr.content.push({
|
2025-07-03 15:54:39 +08:00
|
|
|
|
name: '全景图' ,
|
2025-07-03 13:54:01 +08:00
|
|
|
|
url: this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value
|
|
|
|
|
})
|
|
|
|
|
this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value = ''
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.Dialog.clickAddVr && this.Dialog.clickAddVr()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addAttributeRr(vr) {
|
|
|
|
|
this.options.attribute.vr.content.push({
|
2025-07-03 15:54:39 +08:00
|
|
|
|
name: '全景图' ,
|
2025-07-03 13:54:01 +08:00
|
|
|
|
url: vr
|
|
|
|
|
})
|
|
|
|
|
this.attributeVr = this.options.attribute.vr.content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 打开富文本框
|
|
|
|
|
*/
|
|
|
|
|
openRichTextEditor(e) {
|
|
|
|
|
richText.open(this.options.id, this.options.name, this.options.richTextContent)
|
|
|
|
|
richText.primaryCallBack = (content) => {
|
|
|
|
|
this.options.richTextContent = content
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**@desc 打开平移功能
|
|
|
|
|
*
|
|
|
|
|
* @memberOf Source
|
|
|
|
|
* @param status {boolean}
|
|
|
|
|
*
|
|
|
|
|
* */
|
|
|
|
|
set positionEditing(status) {
|
|
|
|
|
if (YJ.Measure.GetMeasureStatus() || !this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let _this = this
|
|
|
|
|
this.event && this.event.destroy()
|
|
|
|
|
this.event = new MouseEvent(this.sdk)
|
|
|
|
|
this.operate.positionEditing = status
|
|
|
|
|
this.previous = {
|
|
|
|
|
positions: [...this.positions]
|
|
|
|
|
}
|
|
|
|
|
if (status === true) {
|
|
|
|
|
this.tip && this.tip.destroy()
|
|
|
|
|
this.tip = new MouseTip('点击鼠标左键确认,右键取消', this.sdk)
|
|
|
|
|
this.label && (this.label.entity.billboard.color = Cesium.Color.fromCssColorString(`rgba(255,255,255,0.9)`))
|
|
|
|
|
this.picking = false
|
|
|
|
|
let array = []
|
|
|
|
|
let positions = [...this.positions]
|
|
|
|
|
let positions84 = this.options.positions
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
|
|
|
|
|
let disparity = []
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
let position = this.cartesian3Towgs84(positions[i], this.sdk.viewer)
|
|
|
|
|
array.push([position.lng, position.lat])
|
|
|
|
|
}
|
|
|
|
|
let firstposition = this.cartesian3Towgs84(positions[0], this.sdk.viewer)
|
|
|
|
|
array.push([firstposition.lng, firstposition.lat])
|
|
|
|
|
var polygon = turf.polygon([array]);
|
|
|
|
|
var centroid = turf.centroid(polygon);
|
|
|
|
|
let center = Cesium.Cartesian3.fromDegrees(...centroid.geometry.coordinates)
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
disparity.push({
|
|
|
|
|
x: center.x - positions[i].x,
|
|
|
|
|
y: center.y - positions[i].y,
|
|
|
|
|
z: center.z - positions[i].z,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
let newpositions = []
|
|
|
|
|
let leftEvent = (movement, cartesian) => {
|
|
|
|
|
this.event.mouse_move(() => { })
|
|
|
|
|
this.event.mouse_left(() => { })
|
|
|
|
|
this.event.mouse_right(() => { })
|
|
|
|
|
newpositions = []
|
|
|
|
|
for (let i = 0; i < disparity.length; i++) {
|
|
|
|
|
let pos3 = {
|
|
|
|
|
x: cartesian.x - disparity[i].x,
|
|
|
|
|
y: cartesian.y - disparity[i].y,
|
|
|
|
|
z: cartesian.z - disparity[i].z,
|
|
|
|
|
}
|
|
|
|
|
newpositions.push(pos3)
|
|
|
|
|
this.options.positions[i] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fromDegreesArray = []
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
for (let i = 0; i < positions84.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions84[i].lng, positions84[i].lat, this.options.height)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
this.previous.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions84.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions84[i].lng, positions84[i].lat)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
this.previous.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
this.positionEditing = false
|
|
|
|
|
}
|
|
|
|
|
this.event.mouse_move((movement, cartesian) => {
|
|
|
|
|
let position84 = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
|
|
|
|
newpositions = []
|
|
|
|
|
for (let i = 0; i < disparity.length; i++) {
|
|
|
|
|
let pos3 = {
|
|
|
|
|
x: cartesian.x - disparity[i].x,
|
|
|
|
|
y: cartesian.y - disparity[i].y,
|
|
|
|
|
z: cartesian.z - disparity[i].z,
|
|
|
|
|
}
|
|
|
|
|
newpositions.push(pos3)
|
|
|
|
|
this.options.positions[i] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
|
|
|
|
}
|
|
|
|
|
fromDegreesArray = []
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
for (let i = 0; i < positions84.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions84[i].lng, positions84[i].lat, this.options.height)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions84.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions84[i].lng, positions84[i].lat)
|
|
|
|
|
}
|
|
|
|
|
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
this.label.position = [position84.lng, position84.lat, this.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.getClampToHeight({ lng: position84.lng, lat: position84.lat }).then((height) => {
|
|
|
|
|
this.label.position = [position84.lng, position84.lat, height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.tip.setPosition(
|
|
|
|
|
cartesian,
|
|
|
|
|
movement.endPosition.x,
|
|
|
|
|
movement.endPosition.y
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
this.event.mouse_left(leftEvent)
|
|
|
|
|
this.event.mouse_right((movement, cartesian) => {
|
|
|
|
|
this.positions = [...this.previous.positions]
|
|
|
|
|
this.positionEditing = false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.event.gesture_pinck_start((movement, cartesian) => {
|
|
|
|
|
let startTime = new Date()
|
|
|
|
|
let pos = {
|
|
|
|
|
position: {
|
|
|
|
|
x: (movement.position1.x + movement.position2.x) / 2,
|
|
|
|
|
y: (movement.position1.y + movement.position2.y) / 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.event.gesture_pinck_end(() => {
|
|
|
|
|
let endTime = new Date()
|
|
|
|
|
if (endTime - startTime >= 500) {
|
|
|
|
|
// 长按取消
|
|
|
|
|
this.positionEditing = false
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
leftEvent(pos, cartesian)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
|
|
|
|
return new Cesium.PolygonHierarchy(_this.positions)
|
|
|
|
|
}, false)
|
|
|
|
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
|
|
|
return [..._this.positions, _this.positions[0], _this.positions[1]]
|
|
|
|
|
}, false)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(this.label && this.label.entity && this.label.entity.billboard)
|
|
|
|
|
{
|
|
|
|
|
this.label.entity.billboard.color = Cesium.Color.fromCssColorString(`rgba(255,255,255,1)`)
|
|
|
|
|
}
|
|
|
|
|
this.picking = true
|
|
|
|
|
if (this.event) {
|
|
|
|
|
this.event.mouse_move(() => { })
|
|
|
|
|
this.event.mouse_left(() => { })
|
|
|
|
|
this.event.mouse_right(() => { })
|
|
|
|
|
this.event.destroy()
|
|
|
|
|
}
|
|
|
|
|
this.tip && this.tip.destroy()
|
|
|
|
|
let positions = [[]]
|
|
|
|
|
for (let i = 0; i < this.previous.positions.length; i++) {
|
|
|
|
|
let positions84 = this.cartesian3Towgs84(this.previous.positions[i], this.sdk.viewer)
|
|
|
|
|
positions[0].push([positions84.lng, positions84.lat])
|
|
|
|
|
}
|
|
|
|
|
let positions84 = this.cartesian3Towgs84(this.previous.positions[0], this.sdk.viewer)
|
|
|
|
|
positions[0].push([positions84.lng, positions84.lat])
|
|
|
|
|
let polygon = turf.polygon(positions);
|
|
|
|
|
let centroid = turf.centroid(polygon);
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
this.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], this.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }).then((height) => {
|
|
|
|
|
this.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
|
|
|
|
return new Cesium.PolygonHierarchy(_this.previous.positions)
|
|
|
|
|
}, true)
|
|
|
|
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
|
|
|
return [..._this.previous.positions, _this.previous.positions[0], _this.previous.positions[1]]
|
|
|
|
|
}, true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get positionEditing() {
|
|
|
|
|
return this.operate.positionEditing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EventBinding(that, elements) {
|
|
|
|
|
for (let i = 0; i < elements.length; i++) {
|
|
|
|
|
let Event = []
|
|
|
|
|
let isEvent = false
|
|
|
|
|
let removeName = []
|
|
|
|
|
if (!elements[i] || !elements[i].attributes) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for (let m of elements[i].attributes) {
|
|
|
|
|
switch (m.name) {
|
|
|
|
|
case '@model': {
|
|
|
|
|
isEvent = true
|
|
|
|
|
if (elements[i].type == 'checkbox') {
|
|
|
|
|
Event.push((e) => { that[m.value] = e.target.checked })
|
|
|
|
|
elements[i].checked = that[m.value]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Event.push((e) => {
|
|
|
|
|
let value = e.target.value
|
|
|
|
|
if (e.target.type == 'number') {
|
|
|
|
|
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
|
|
|
|
value = Number(value)
|
|
|
|
|
if ((e.target.max) && value > Number(e.target.max)) {
|
|
|
|
|
value = Number(e.target.max)
|
|
|
|
|
}
|
|
|
|
|
if ((e.target.min) && value < Number(e.target.min)) {
|
|
|
|
|
value = Number(e.target.min)
|
|
|
|
|
}
|
|
|
|
|
that[m.value] = value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that[m.value] = value
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (elements[i].nodeName == 'IMG') {
|
|
|
|
|
elements[i].src = that[m.value]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
elements[i].value = that[m.value]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (that._elms[m.value]) {
|
|
|
|
|
that._elms[m.value].push(elements[i])
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that._elms[m.value] = [elements[i]]
|
|
|
|
|
}
|
|
|
|
|
removeName.push(m.name)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case '@click': {
|
|
|
|
|
elements[i].addEventListener('click', (e) => {
|
|
|
|
|
if (typeof (that[m.value]) === 'function') {
|
|
|
|
|
that[m.value](e)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
removeName.push(m.name)
|
|
|
|
|
// elements[i].attributes.removeNamedItem(m.name)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case '@change': {
|
|
|
|
|
isEvent = true
|
|
|
|
|
Event.push((e) => {
|
|
|
|
|
let value = e.target.value
|
|
|
|
|
if (e.target.type == 'number' && value != '') {
|
|
|
|
|
value = Number(value)
|
|
|
|
|
e.target.value = value
|
|
|
|
|
}
|
|
|
|
|
if (typeof (that[m.value]) === 'function') {
|
|
|
|
|
that[m.value](e, value)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// elements[i].attributes[m] = undefined
|
|
|
|
|
}
|
|
|
|
|
for (let n = 0; n < removeName.length; n++) {
|
|
|
|
|
elements[i].attributes.removeNamedItem(removeName[n])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isEvent) {
|
|
|
|
|
let ventType = 'input'
|
|
|
|
|
if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') {
|
|
|
|
|
ventType = 'change'
|
|
|
|
|
}
|
|
|
|
|
elements[i].addEventListener(ventType, (e) => {
|
|
|
|
|
for (let t = 0; t < Event.length; t++) {
|
|
|
|
|
Event[t](e)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static nodeEdit(that, cb = () => { }) {
|
|
|
|
|
that.positionEditing = false
|
|
|
|
|
if (YJ.Measure.GetMeasureStatus()) {
|
|
|
|
|
cb('上一次测量未结束')
|
|
|
|
|
} else {
|
|
|
|
|
YJ.Measure.SetMeasureStatus(true)
|
|
|
|
|
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
|
|
|
|
that.event = new MouseEvent(that.sdk)
|
|
|
|
|
that.nodePoints = []
|
|
|
|
|
let selectPoint
|
|
|
|
|
let originalPosition
|
|
|
|
|
let newpositions = []
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(that.options.positions[i].lng, that.options.positions[i].lat, that.options.height)
|
|
|
|
|
}
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(that.options.positions[i].lng, that.options.positions[i].lat)
|
|
|
|
|
}
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let leftEvent = async (movement, cartesian) => {
|
|
|
|
|
if (selectPoint) {
|
|
|
|
|
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
|
|
|
|
originalPosition = that.options.positions[selectPoint.index]
|
|
|
|
|
let potHeight = (!that.ground) ? that.options.height : await that.getClampToHeight(that.options.positions[selectPoint.index])
|
|
|
|
|
let entity = that.sdk.viewer.entities.add({
|
|
|
|
|
name: 'node-secondary-edit-point',
|
|
|
|
|
position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, potHeight),
|
|
|
|
|
billboard: {
|
|
|
|
|
image: that.getSourceRootPath() + '/img/point.png',
|
|
|
|
|
width: 15,
|
|
|
|
|
height: 15,
|
|
|
|
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
|
|
color: Cesium.Color.WHITE.withAlpha(0.99)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
that.nodePoints.splice(selectPoint.index, 0, entity)
|
|
|
|
|
that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let positions = that.options.positions
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, that.options.height)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (that.options.positions.length < 3) {
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
that.label.position = [that.options.positions[0].lng, that.options.positions[0].lat, that.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that.getClampToHeight({ lng: that.options.positions[0].lng, lat: that.options.positions[0].lat }).then((height) => {
|
|
|
|
|
that.label.position = [that.options.positions[0].lng, that.options.positions[0].lat, height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let positions = [[]]
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
positions[0].push([that.options.positions[i].lng, that.options.positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions[0].push([that.options.positions[0].lng, that.options.positions[0].lat])
|
|
|
|
|
let polygon = turf.polygon(positions);
|
|
|
|
|
let centroid = turf.centroid(polygon);
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], that.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }).then((height) => {
|
|
|
|
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
that.options.areaByMeter = that.computeArea(that.options.positions);
|
|
|
|
|
switch (that.options['area-unit']) {
|
|
|
|
|
case '平方米':
|
|
|
|
|
that.area = that.options.areaByMeter
|
|
|
|
|
break;
|
|
|
|
|
case '平方千米':
|
|
|
|
|
that.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
|
|
|
break;
|
|
|
|
|
case '亩':
|
|
|
|
|
that.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
|
|
|
break;
|
|
|
|
|
case '公顷':
|
|
|
|
|
that.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
that.area = that.options.areaByMeter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
var pick = that.sdk.viewer.scene.pick(movement.position);
|
|
|
|
|
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
|
|
|
|
selectPoint = pick.id
|
|
|
|
|
that.nodePoints.splice(pick.id.index, 1)
|
|
|
|
|
that.sdk.viewer.entities.remove(pick.id)
|
|
|
|
|
that.tip.set_text('左键开始,右键结束,CTRL+右键撤销')
|
|
|
|
|
originalPosition = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let rightEvent = (movement, cartesian) => {
|
|
|
|
|
if (selectPoint) {
|
|
|
|
|
that.options.positions[selectPoint.index] = originalPosition
|
|
|
|
|
that.options.positions.splice(selectPoint.index, 1)
|
|
|
|
|
let positions = that.options.positions
|
|
|
|
|
that.options.areaByMeter = that.computeArea(that.options.positions);
|
|
|
|
|
switch (that.options['area-unit']) {
|
|
|
|
|
case '平方米':
|
|
|
|
|
that.area = that.options.areaByMeter
|
|
|
|
|
break;
|
|
|
|
|
case '平方千米':
|
|
|
|
|
that.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
|
|
|
break;
|
|
|
|
|
case '亩':
|
|
|
|
|
that.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
|
|
|
break;
|
|
|
|
|
case '公顷':
|
|
|
|
|
that.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
that.area = that.options.areaByMeter
|
|
|
|
|
}
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, that.options.height)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (that.options.positions.length < 3) {
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
that.label.position = [that.options.positions[0].lng, that.options.positions[0].lat, that.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that.getClampToHeight({ lng: that.options.positions[0].lng, lat: that.options.positions[0].lat }).then((height) => {
|
|
|
|
|
that.label.position = [that.options.positions[0].lng, that.options.positions[0].lat, height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let positions2 = [[]]
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
positions2[0].push([that.options.positions[i].lng, that.options.positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions2[0].push([that.options.positions[0].lng, that.options.positions[0].lat])
|
|
|
|
|
let polygon = turf.polygon(positions2);
|
|
|
|
|
let centroid = turf.centroid(polygon);
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], that.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }).then((height) => {
|
|
|
|
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let positions = []
|
|
|
|
|
// cache_positions.forEach((item) => {
|
|
|
|
|
// positions.push(this.cartesian3Towgs84(item, this.viewer))
|
|
|
|
|
// })
|
|
|
|
|
cb(null, that.options.positions)
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < that.nodePoints.length; i++) {
|
|
|
|
|
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
|
|
|
|
}
|
|
|
|
|
that.nodePoints = []
|
|
|
|
|
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
|
|
|
|
return new Cesium.PolygonHierarchy(newpositions)
|
|
|
|
|
}, true)
|
|
|
|
|
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
|
|
|
if (newpositions.length >= 3) {
|
|
|
|
|
return [...newpositions, newpositions[0], newpositions[1], newpositions[2]]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return newpositions
|
|
|
|
|
}
|
|
|
|
|
}, true)
|
|
|
|
|
YJ.Measure.SetMeasureStatus(false)
|
|
|
|
|
that.event.destroy()
|
|
|
|
|
that.tip.destroy()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
that.event.mouse_left(leftEvent)
|
|
|
|
|
|
|
|
|
|
that.event.mouse_right(rightEvent)
|
|
|
|
|
|
|
|
|
|
that.event.mouse_move((movement, cartesian) => {
|
|
|
|
|
if (selectPoint) {
|
|
|
|
|
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
|
|
|
|
let positions = that.options.positions
|
|
|
|
|
let fromDegreesArray = []
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat, that.options.height)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
|
|
|
|
}
|
|
|
|
|
that.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
|
|
|
|
}
|
|
|
|
|
if (that.options.positions.length < 3) {
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
that.label.position = [that.options.positions[0].lng, that.options.positions[0].lat, that.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that.getClampToHeight({ lng: that.options.positions[0].lng, lat: that.options.positions[0].lat }).then((height) => {
|
|
|
|
|
that.label.position = [that.options.positions[0].lng, that.options.positions[0].lat, height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let positions = [[]]
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
positions[0].push([that.options.positions[i].lng, that.options.positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions[0].push([that.options.positions[0].lng, that.options.positions[0].lat])
|
|
|
|
|
let polygon = turf.polygon(positions);
|
|
|
|
|
let centroid = turf.centroid(polygon);
|
|
|
|
|
if (!that.ground) {
|
|
|
|
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], that.options.height]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
that.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }).then((height) => {
|
|
|
|
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
that.tip.setPosition(
|
|
|
|
|
cartesian,
|
|
|
|
|
movement.endPosition.x,
|
|
|
|
|
movement.endPosition.y
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
|
|
|
|
if (selectPoint) {
|
|
|
|
|
that.options.positions.pop()
|
|
|
|
|
that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1])
|
|
|
|
|
that.nodePoints.pop()
|
|
|
|
|
if (selectPoint.index === that.options.positions.length) {
|
|
|
|
|
if (that.nodePoints[selectPoint.index - 1]) {
|
|
|
|
|
selectPoint = that.nodePoints[selectPoint.index - 1]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
selectPoint.index = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
that.event.gesture_pinck_start((movement, cartesian) => {
|
|
|
|
|
let startTime = new Date()
|
|
|
|
|
let pos = {
|
|
|
|
|
position: {
|
|
|
|
|
x: (movement.position1.x + movement.position2.x) / 2,
|
|
|
|
|
y: (movement.position1.y + movement.position2.y) / 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
that.event.gesture_pinck_end(() => {
|
|
|
|
|
let endTime = new Date()
|
|
|
|
|
if (endTime - startTime >= 500) {
|
|
|
|
|
// 长按取消
|
|
|
|
|
rightEvent(pos, cartesian)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
leftEvent(pos, cartesian)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
|
|
|
|
return new Cesium.PolygonHierarchy(newpositions)
|
|
|
|
|
}, false)
|
|
|
|
|
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
|
|
|
if (newpositions.length >= 3) {
|
|
|
|
|
return [...newpositions, newpositions[0], newpositions[1], newpositions[2]]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return newpositions
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
|
|
|
|
|
createNodePoints()
|
|
|
|
|
|
|
|
|
|
async function createNodePoints() {
|
|
|
|
|
for (let i = 0; i < that.options.positions.length; i++) {
|
|
|
|
|
let height = (!that.ground) ? that.options.height : await that.getClampToHeight(that.options.positions[i])
|
|
|
|
|
let entity = that.sdk.viewer.entities.add({
|
|
|
|
|
name: 'node-secondary-edit-point',
|
|
|
|
|
index: i,
|
|
|
|
|
position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat, height),
|
|
|
|
|
billboard: {
|
|
|
|
|
image: that.getSourceRootPath() + '/img/point.png',
|
|
|
|
|
width: 15,
|
|
|
|
|
height: 15,
|
|
|
|
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
|
|
color: Cesium.Color.WHITE.withAlpha(0.99)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
that.nodePoints.push(entity)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setPosition(v) {
|
|
|
|
|
let cartesian = Cesium.Cartesian3.fromDegrees(v.position.lng, v.position.lat, v.position.alt)
|
|
|
|
|
let positions = [...this.positions]
|
|
|
|
|
let array = []
|
|
|
|
|
let disparity = []
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
let position = this.cartesian3Towgs84(positions[i], this.sdk.viewer)
|
|
|
|
|
array.push([position.lng, position.lat])
|
|
|
|
|
}
|
|
|
|
|
let firstposition = this.cartesian3Towgs84(positions[0], this.sdk.viewer)
|
|
|
|
|
array.push([firstposition.lng, firstposition.lat])
|
|
|
|
|
var polygon = turf.polygon([array]);
|
|
|
|
|
var centroid = turf.centroid(polygon);
|
|
|
|
|
let center = Cesium.Cartesian3.fromDegrees(...centroid.geometry.coordinates)
|
|
|
|
|
for (let i = 0; i < positions.length; i++) {
|
|
|
|
|
disparity.push({
|
|
|
|
|
x: center.x - positions[i].x,
|
|
|
|
|
y: center.y - positions[i].y,
|
|
|
|
|
z: center.z - positions[i].z,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
let newpositions = []
|
|
|
|
|
for (let i = 0; i < disparity.length; i++) {
|
|
|
|
|
newpositions.push({
|
|
|
|
|
x: cartesian.x - disparity[i].x,
|
|
|
|
|
y: cartesian.y - disparity[i].y,
|
|
|
|
|
z: cartesian.z - disparity[i].z,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
this.label.position = [v.position.lng, v.position.lat, v.position.alt]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.getClampToHeight({ lng: v.position.lng, lat: v.position.lat }).then((height) => {
|
|
|
|
|
this.label.position = [v.position.lng, v.position.lat, height]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
|
|
|
|
if (newpositions.length > 0) {
|
|
|
|
|
return new Cesium.PolygonHierarchy(newpositions)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return new Cesium.PolygonHierarchy(positions)
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
|
|
|
if (newpositions.length > 0) {
|
|
|
|
|
return [...newpositions, newpositions[0], newpositions[1]]
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return [...positions, positions[0], positions[1]]
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async setDIV(options = { domid: "", x: 10, y: 10 }) {
|
|
|
|
|
options.x = (options.x || options.x === 0) ? options.x : 10
|
|
|
|
|
options.y = (options.y || options.y === 0) ? options.y : 10
|
|
|
|
|
|
|
|
|
|
let positions = [[]]
|
|
|
|
|
for (let i = 0; i < this.options.positions.length; i++) {
|
|
|
|
|
positions[0].push([this.options.positions[i].lng, this.options.positions[i].lat])
|
|
|
|
|
}
|
|
|
|
|
positions[0].push([this.options.positions[0].lng, this.options.positions[0].lat])
|
|
|
|
|
let polygon = turf.polygon(positions);
|
|
|
|
|
let centroid = turf.pointOnFeature(polygon);
|
|
|
|
|
let height
|
|
|
|
|
if (!this.ground) {
|
|
|
|
|
height = this.options.height
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
height = await this.getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let siteInfoDom = document.getElementById(options.domid)
|
|
|
|
|
let siteInfoPosition = Cesium.Cartesian3.fromDegrees(centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height)
|
|
|
|
|
|
|
|
|
|
this.sdk.viewer.scene.postRender.addEventListener((percentage) => {
|
|
|
|
|
//转换到屏幕坐标
|
|
|
|
|
if (siteInfoDom.style.display === 'block' || siteInfoDom.style.display === '') {
|
|
|
|
|
let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates(siteInfoPosition);
|
|
|
|
|
if (winpos) {
|
|
|
|
|
siteInfoDom.style.left = (winpos.x + options.x).toFixed(0) + 'px';
|
|
|
|
|
siteInfoDom.style.top = (winpos.y + options.y).toFixed(0) + 'px';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PolygonObject
|