Files
sdk4.0/src/Obj/Base/CircleDiffuse/index.js

1594 lines
57 KiB
JavaScript
Raw Normal View History

2025-07-03 13:54:01 +08:00
import Base from "../index";
import cy_tabs from "../../Element/cy_html_tabs";
import { html } from "./_element";
import Dialog from '../../Element/Dialog';
import EventBinding from '../../Element/Dialog/eventBinding';
import richText from "../../Element/richText";
import MouseEvent from '../../../Event/index'
import LabelObject from '../LabelObject'
2025-08-13 11:51:39 +08:00
import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
2025-07-03 13:54:01 +08:00
import { legp } from '../../Element/datalist';
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import MouseTip from '../../../MouseTip'
import CircleDiffuseMaterialProperty from '../../Materail/CircleRippleMaterialProperty'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global'
class CircleDiffuse extends Base {
/**
* @constructor
* @description 扩散圆
* @param sdk
* @param options {object} 圆属性
* @param options.id {string} 标注id
* @param [options.show=true] {boolean} 显示/隐藏
* @param options.lng {number} 经度
* @param options.lat {number} 维度
* @param options.color=#1FA8E3 {string} 基础颜色
* @param options.colors=[] {string} 范围颜色
* @param options.speed=5 {number} 速度
* @param options.count=3 {number} 波纹数量
* @param options.circle=[{radius, color}] {object} 圆属性radius:半径color:颜色
* @param _Dialog {object} 弹框事件
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
*/
constructor(sdk, options = {}, _Dialog = {}) {
super(sdk, options);
this.options.lng = options.lng
this.options.lat = options.lat
this.options.color = options.color || '#1FA8E3'
this.options.colors = options.colors || []
this.options.transparency = (options.transparency || options.transparency === 0) ? options.transparency : 1
if (this.options.transparency > 1) {
this.options.transparency = 1
}
this.options.speed = (options.speed || options.speed === 0) ? options.speed : 5
this.options.count = (options.count || options.count === 0) ? options.count : 3
if (options.count || options.count === 0) {
this.options.count = options.count
if (options.count > 99) {
this.options.count = 99
}
}
else {
this.options.count = 3
}
this.options.circle = options.circle || [{ radius: 10 }]
for (let i = 0; i < this.options.circle.length; i++) {
if(this.options.circle[i].radius>999999) {
this.options.circle[i].radius = 999999
}
}
this.options.show = (options.show || options.show === false) ? options.show : true
this.event = new MouseEvent(this.sdk)
this.options.positionEditin = false
options.label = options.label || {}
this._elms = {};
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,
fontFamily: options.label.fontFamily ? options.label.fontFamily : 0,
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,
2025-07-09 11:15:53 +08:00
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
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.instruct = options.instruct || ''
this.options.operatingPoint = options.operatingPoint || ''
this.options.attribute = options.attribute || {}
this.options.attribute.vr = this.options.attribute.vr || {}
this.options.attribute.vr.content = this.options.attribute.vr.content || []
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.ISC = this.options.attribute.ISC || {}
this.options.attribute.ISC.content = this.options.attribute.ISC.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'
let radius = 0
for (let i = 0; i < this.options.circle.length; i++) {
if (Number(this.options.circle[i].radius) > radius) {
radius = Number(this.options.circle[i].radius)
}
}
this._radius = radius
this.Dialog = _Dialog
this._EventBinding = new EventBinding()
this.sdk.addIncetance(this.options.id, this)
CircleDiffuse.create(this)
// this.sdk.addIncetance(this.options.id, {
// type: 'CircleDiffuse',
// options: options
// })
}
static create(that) {
let colors = {}
for (let i = 0; i < that.options.circle.length; i++) {
colors[that.options.circle[i].radius / that.radius] = Cesium.Color.fromCssColorString(that.options.circle[i].color || that.options.color)
}
let zIndex = that.sdk._entityZIndex
if (that.entity) {
zIndex = that.entity.ellipse.zIndex._value
that.sdk.viewer.entities.remove(that.entity)
that.entity = that.sdk.viewer.entities.add({
id: that.options.id,
show: that.options.show,
position: new Cesium.CallbackProperty(function () {
return Cesium.Cartesian3.fromDegrees(that.options.lng, that.options.lat)
}, false),
name: "波纹圆",
ellipse: {
semiMinorAxis: new Cesium.CallbackProperty(function () {
return that.radius
}, false),
semiMajorAxis: new Cesium.CallbackProperty(function () {
return that.radius
}, false),
material: new CircleDiffuseMaterialProperty({
id: that.options.id,
colors: colors,
transparency: that.options.transparency,
speed: that.options.speed,
count: that.options.count,
gradient: 0.2
}),
zIndex: zIndex
}
})
}
else {
that.entity = that.sdk.viewer.entities.add({
id: that.options.id,
show: that.options.show,
position: new Cesium.CallbackProperty(function () {
return Cesium.Cartesian3.fromDegrees(that.options.lng, that.options.lat)
}, false),
name: "波纹圆",
ellipse: {
semiMinorAxis: new Cesium.CallbackProperty(function () {
return that.radius
}, false),
semiMajorAxis: new Cesium.CallbackProperty(function () {
return that.radius
}, false),
material: new CircleDiffuseMaterialProperty({
id: that.options.id,
colors: colors,
transparency: that.options.transparency,
speed: that.options.speed,
count: that.options.count,
gradient: 0.2
}),
zIndex: zIndex
}
})
if (that.options.show) {
setSplitDirection(0, that.options.id)
}
that.sdk._entityZIndex++
if (that.sdk.viewer._element.className === 'cesium-viewer 2d') {
2025-08-25 10:42:54 +08:00
that.entity.ellipse.height = 1
2025-07-03 13:54:01 +08:00
}
CircleDiffuse.createLabel(that)
syncData(that.sdk, that.options.id)
}
}
static async createLabel(that) {
if (!that.options.label.position) {
let height = await that.getClampToHeight({ lng: that.options.lng, lat: that.options.lat })
that.options.label.position = { lng: that.options.lng, lat: that.options.lat, 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,
fontFamily: that.options.label.fontFamily,
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,
ground: true
})
}
get type() {
return 'CircleDiffuse'
}
get show() {
return this.options.show
}
set show(v) {
if (typeof v === "boolean") {
2025-08-13 11:51:39 +08:00
let sdkD = get2DSdk().sdkD
if (!this.isShowView || !sdkD) {
this.options.show = v
}
2025-08-13 11:51:39 +08:00
if (!this.showView || this.showView == 3 || !sdkD) {
this.entity.show = this.options.show
if (this.options.label.show) {
this.label.show = this.options.show
}
}
else {
this.entity.show = false
if (this.options.label.show) {
this.label.show = false
}
}
this.isShowView = false
2025-07-03 13:54:01 +08:00
syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
if (this._DialogObject && this._DialogObject.showBtn) {
this._DialogObject.showBtn.checked = v
}
2025-07-03 13:54:01 +08:00
} else {
console.error("参数必须为boolean")
}
}
/**@desc
*
* @memberOf Source
* @param status {boolean}
*
* */
set positionEditing(status) {
if (!this.sdk || !this.sdk.viewer || !this.entity) {
return
}
this.options.positionEditing = status
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
this.lastOptions = {
lng: this.options.lng,
lat: this.options.lat
}
this.event.mouse_move((movement, cartesian) => {
let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
this.lng = positions.lng
this.lat = positions.lat
this.tip.setPosition(
cartesian,
movement.endPosition.x,
movement.endPosition.y
)
})
this.event.mouse_left((movement, cartesian) => {
let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
this.lng = positions.lng
this.lat = positions.lat
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
this.event.gesture_pinck_start(() => { })
this.event.gesture_pinck_end(() => { })
this.lastOptions = undefined
this.positionEditing = false
})
this.event.mouse_right((movement, cartesian) => {
this.positionEditing = false
})
this.event.gesture_pinck_start((movement, cartesian) => {
let startTime = new Date()
this.event.gesture_pinck_end(() => {
let endTime = new Date()
if (endTime - startTime >= 500) {
// 长按取消
this.positionEditing = false
}
else {
let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
this.lng = positions.lng
this.lat = positions.lat
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
this.event.gesture_pinck_start(() => { })
this.event.gesture_pinck_end(() => { })
this.lastOptions = undefined
this.positionEditing = false
}
})
})
}
else {
setTimeout(() => {
this.picking = true
}, 500);
if(this.label && this.label.entity && this.label.entity.billboard)
{
this.label.entity.billboard.color = Cesium.Color.fromCssColorString(`rgba(255,255,255,1)`)
}
if (this.event) {
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
}
this.tip && this.tip.destroy()
if (this.lastOptions) {
this.lng = this.lastOptions.lng
this.lat = this.lastOptions.lat
}
this.lastOptions = undefined
}
}
get positionEditing() {
return this.options.positionEditing
}
get lng() {
return this.options.lng
}
set lng(v) {
this.options.lng = v
this.label.position = [v, this.lat]
this._elms.lng && this._elms.lng.forEach((item) => {
item.value = v
})
}
get lat() {
return this.options.lat
}
set lat(v) {
this.options.lat = v
this.label.position = [this.lng, v]
this._elms.lat && this._elms.lat.forEach((item) => {
item.value = v
})
}
get radius() {
return this._radius
}
get circle() {
return this.options.circle
}
set circle(v) {
2025-08-06 14:19:09 +08:00
console.log(v)
2025-07-03 13:54:01 +08:00
this.options.circle = v || [{ radius: 10 }]
for (let i = 0; i < this.options.circle.length; i++) {
if(this.options.circle[i].radius>999999) {
this.options.circle[i].radius = 999999
}
}
this._createCircleElm()
}
get speed() {
return this.options.speed
}
set speed(v) {
this.options.speed = v
CircleDiffuse.create(this)
this._elms.speed && this._elms.speed.forEach((item) => {
item.value = v
})
}
get transparency() {
return this.options.transparency
}
set transparency(v) {
if (v > 1) {
this.options.transparency = 1
}
else {
this.options.transparency = v
}
CircleDiffuse.create(this)
this._elms.transparency && this._elms.transparency.forEach((item) => {
item.value = v
})
}
get count() {
return this.options.count
}
set count(v) {
if (v > 99) {
this.options.count = 99
}
else {
this.options.count = v
}
CircleDiffuse.create(this)
this._elms.count && this._elms.count.forEach((item) => {
item.value = v
})
}
get colors() {
return this.options.colors
}
set colors(v) {
this.options.colors = v
CircleDiffuse.create(this)
}
get labelShow() {
return this.options.label.show
}
set labelShow(v) {
2025-08-13 11:51:39 +08:00
let sdkD = get2DSdk().sdkD
2025-07-03 13:54:01 +08:00
this.options.label.show = v
2025-08-13 11:51:39 +08:00
if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
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 labelFontFamily() {
return this.options.label.fontFamily
}
set labelFontFamily(v) {
this.options.label.fontFamily = v || 0
this.label && (this.label.fontFamily = this.options.label.fontFamily)
let name = getFontFamilyName(this.labelFontFamily) || ''
this._elms.labelFontFamily &&
this._elms.labelFontFamily.forEach(item => {
item.value = name
})
}
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: () => {
2025-07-09 11:15:53 +08:00
this.labelLineColor = 'rgba(0,255,255,0.5)'
2025-07-03 13:54:01 +08:00
},//点击清空按钮事件回调
})
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 instruct() {
return this.options.instruct
}
set instruct(v) {
this.options.instruct = v
this._elms.instruct && this._elms.instruct.forEach((item) => {
item.value = v
})
}
get operatingPoint() {
return this.options.operatingPoint
}
set operatingPoint(v) {
this.options.operatingPoint = v
this._elms.operatingPoint && this._elms.operatingPoint.forEach((item) => {
item.value = v
})
}
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">` + this.options.attribute.link.content[i].name + `</div>
<div class="td">` + this.options.attribute.link.content[i].url + `</div>
<div class="td">
<button @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">
<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.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 attributeISC() {
return this.options.attribute.ISC.content
}
set attributeISC(v) {
this.options.attribute.ISC.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
}
async flyTo(options = {}) {
setActiveViewer(0)
closeRotateAround(this.sdk)
closeViewFollow(this.sdk)
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
let orientation = {
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
}
let lng = this.options.customView.relativePosition.lng
let lat = this.options.customView.relativePosition.lat
let alt = this.options.customView.relativePosition.alt
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
let position = { lng: 0, lat: 0 }
if (this.options.position) {
position = { ...this.options.position }
}
else if (this.options.positions) {
position = { ...this.options.positions[0] }
}
else if (this.options.center) {
position = { ...this.options.center }
}
else if (this.options.start) {
position = { ...this.options.start }
}
else {
if (this.options.hasOwnProperty('lng')) {
position.lng = this.options.lng
}
if (this.options.hasOwnProperty('lat')) {
position.lat = this.options.lat
}
if (this.options.hasOwnProperty('alt')) {
position.alt = this.options.alt
}
}
// 如果没有高度值,则获取紧贴高度计算
if (!position.hasOwnProperty('alt')) {
position.alt = await this.getClampToHeight(position)
}
lng = this.options.customView.relativePosition.lng + position.lng
lat = this.options.customView.relativePosition.lat + position.lat
alt = this.options.customView.relativePosition.alt + position.alt
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
this.sdk.viewer.camera.flyTo({
destination: destination,
orientation: orientation
})
}
else {
let height = await this.getClampToHeight({ lng: this.options.lng, lat: this.options.lat })
this.sdk.viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(this.options.lng, this.options.lat, this.radius * 6 + height),
orientation: options.orientation || {
heading: Cesium.Math.toRadians(0.0),
pitch: Cesium.Math.toRadians(-90.0),
roll: Cesium.Math.toRadians(0.0)
},
duration: 1,
});
}
}
// 编辑框
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)
syncSplitData(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.positionEditing = false
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
},
showCallBack: (show) => {
this.options.show = show
this.originalOptions.show = show
this.show = show
this.Dialog.showCallBack && this.Dialog.showCallBack()
},
translationalCallBack: () => {
this.positionEditing = !this.positionEditing
}
}, true)
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' circle-ciffuse'
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
this.attributeISC = this.options.attribute.ISC.content
this._createCircleElm()
// 创建标签页
let tabsElm = new cy_tabs('circle-diffuse-edit-tabs', undefined, this.sdk)
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 all_elm = contentElm.getElementsByTagName("*")
this._EventBinding.on(this, all_elm)
this._elms = this._EventBinding.element
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.ISCSelect && this.ISCSelect()
this.goodsSelect && this.goodsSelect()
this.cameraSelect && this.cameraSelect()
let unitData = [
{
name: '米',
value: '米'
},
{
name: '千米',
value: '千米'
}
]
let unitDataLegpObject = legp(this._DialogObject._element.content.getElementsByClassName('input-radius-unit-box')[0], ".input-radius-unit")
if (unitDataLegpObject) {
unitDataLegpObject.legp_search(unitData)
let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-radius-unit')[0].getElementsByTagName('input')[0]
unitDataLegpElm.value = '米'
unitDataLegpElm.addEventListener('input', () => {
let circleContentElm = this._DialogObject._element.content.getElementsByClassName('circle-content-box')[0]
let circleElms = circleContentElm.getElementsByClassName('input-number')
switch (unitDataLegpElm.value) {
case '米':
for (let i = 0; i < circleElms.length; i++) {
let unitElm = circleElms[i].getElementsByClassName('unit')[0]
let valueElm = circleElms[i].getElementsByTagName('input')[0]
if (unitElm.innerHTML === 'km') {
unitElm.innerHTML = 'm'
valueElm.value = Math.floor(valueElm.value * 1000 * 100) / 100
}
}
break
case '千米':
for (let i = 0; i < circleElms.length; i++) {
let unitElm = circleElms[i].getElementsByClassName('unit')[0]
let valueElm = circleElms[i].getElementsByTagName('input')[0]
if (unitElm.innerHTML === 'm') {
unitElm.innerHTML = 'km'
valueElm.value = Math.floor(Number((valueElm.value / 1000).toFixed(5)) * 100000) / 100000
}
}
break
default:
break
}
})
}
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 fontData = getFontList()
let fontObject = legp(
this._DialogObject._element.content.getElementsByClassName(
'font-select-box'
)[0],
'.font-select'
)
if (fontObject) {
fontObject.legp_search(fontData)
let fontDataLegpElm = this._DialogObject._element.content
.getElementsByClassName('font-select')[0]
.getElementsByTagName('input')[0]
fontDataLegpElm.value = fontData[this.labelFontFamily].value
for (let i = 0; i < fontData.length; i++) {
if (fontData[i].value == fontDataLegpElm.value) {
fontObject.legp_searchActive(fontData[i].value)
break
}
}
fontDataLegpElm.addEventListener('input', () => {
for (let i = 0; i < fontData.length; i++) {
if (fontData[i].value === fontDataLegpElm.value) {
this.labelFontFamily = fontData[i].key
break
}
}
})
this._elms.labelFontFamily = [fontDataLegpElm]
}
}, 0);
}
}
reset() {
if (!this.entity) {
return
}
this.options = this.deepCopyObj(this.originalOptions)
this.name = this.originalOptions.name
this.lng = this.originalOptions.lng
this.lat = this.originalOptions.lat
this.color = this.originalOptions.color
this.duration = this.originalOptions.duration
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.instruct = this.originalOptions.instruct
this.operatingPoint = this.originalOptions.operatingPoint
this.attributeLink = this.options.attribute.link.content
this.attributeVr = this.options.attribute.vr.content
this.attributeCamera = this.options.attribute.camera.content
this.attributeGoods = this.options.attribute.goods.content
this.attributeISC = this.options.attribute.ISC.content
this.cameraSelect && this.cameraSelect()
this.goodsSelect && this.goodsSelect()
let radius = 0
for (let i = 0; i < this.options.circle.length; i++) {
if (Number(this.options.circle[i].radius) > radius) {
radius = Number(this.options.circle[i].radius)
}
}
this._radius = radius
CircleDiffuse.create(this)
}
async remove() {
2025-08-13 11:51:39 +08:00
this.label && this.label.remove()
2025-07-03 13:54:01 +08:00
this.entity && this.sdk.viewer.entities.remove(this.entity)
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
this.entity = null
this.entity2 = null
if (this._DialogObject && !this._DialogObject.isDestroy) {
this._DialogObject.close()
this._DialogObject = null
}
this.tip && this.tip.destroy()
this.event && this.event.destroy()
await this.sdk.removeIncetance(this.options.id)
await syncData(this.sdk, this.options.id)
}
instructSubmit() {
this.Dialog.instructSubmit && this.Dialog.instructSubmit(this.options.id, this.options.label.text, this.instruct)
this.originalOptions.instruct = this.instruct
}
operatingPointSubmit() {
this.Dialog.operatingPointSubmit && this.Dialog.operatingPointSubmit(this.options.id, this.options.label.text, this.operatingPoint)
this.originalOptions.operatingPoint = this.operatingPoint
}
_createCircleElm() {
if (this._DialogObject && this._DialogObject._element && this._DialogObject._element.content) {
let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-radius-unit')[0].getElementsByTagName('input')[0]
let unit = unitDataLegpElm ? unitDataLegpElm.value : '米'
let circleContentElm = this._DialogObject._element.content.getElementsByClassName('circle-content-box')[0]
circleContentElm.innerHTML = ''
for (let i = 0; i < this.options.circle.length; i++) {
let circleElm = document.createElement('div');
circleElm.className = 'row'
let addString = ''
let deleteString = '<button class="circle-minus"><svg class="icon-minus"><use xlink:href="#yj-icon-minus"></use></svg></button>'
if (i === 0 && i === this.options.circle.length - 1) {
deleteString = ''
}
if (i === this.options.circle.length - 1) {
addString = `<button class="circle-add" style="margin-left: 5px;"><svg class="icon-add2"><use xlink:href="#yj-icon-add2"></use></svg></button>`
}
circleElm.innerHTML = `
<div class="col">
<span class="label">半径</span>
<div class="input-number input-number-unit-1">
<input class="input" type="number" title="" min="0" max="999999" style="width: 130px;">
<span class="unit">${unit === '米' ? 'm' : 'km'}</span>
<span class="arrow"></span>
</div>
</div>
<div class="col" style="flex-direction: row-reverse;">
<div class="color"></div>
<span class="label">扩散颜色</span>
</div>
<div class="col" style="flex-direction: row-reverse;">
${addString}
${deleteString}
</div>
`
let inputElm = circleElm.getElementsByClassName('input')[0]
inputElm.value = this.options.circle[i].radius / (unit === '米' ? 1 : 1000)
inputElm.addEventListener('input', (e) => {
let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-radius-unit')[0].getElementsByTagName('input')[0]
let unit = unitDataLegpElm.value
if (e.target.value || e.target.value === 0) {
let value = e.target.value
value = Number(value)
if (e.data != '.' && (e.data != '-' || e.target.value)) {
if (((!e.target.max) && (!e.target.min)) || ((value <= (Number(e.target.max) / (unit === '米' ? 1 : 1000))) && value >= Number(e.target.min))) {
if (unit === '米') {
value = Math.floor(value * 100) / 100
}
else {
value = Math.floor(value * 100000) / 100000
}
this.options.circle[i].radius = value * (unit === '米' ? 1 : 1000)
let radius = 0
for (let i = 0; i < this.options.circle.length; i++) {
if (Number(this.options.circle[i].radius) > radius) {
radius = Number(this.options.circle[i].radius)
}
}
this._radius = radius
2025-08-06 14:19:09 +08:00
// inputElm.value = value
2025-07-03 13:54:01 +08:00
CircleDiffuse.create(this)
}
}
}
})
inputElm.addEventListener('blur', (e) => {
let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-radius-unit')[0].getElementsByTagName('input')[0]
let unit = unitDataLegpElm.value
if (e.target.value || e.target.value === 0) {
let value = e.target.value
value = Number(value)
if ((e.target.max) && value > (Number(e.target.max) / (unit === '米' ? 1 : 1000))) {
value = (Number(e.target.max) / (unit === '米' ? 1 : 1000))
}
if ((e.target.min) && value < Number(e.target.min)) {
value = Number(e.target.min)
}
if (unit === '米') {
value = Math.floor(value * 100) / 100
}
else {
value = Math.floor(value * 100000) / 100000
}
this.options.circle[i].radius = value * (unit === '米' ? 1 : 1000)
let radius = 0
for (let i = 0; i < this.options.circle.length; i++) {
if (Number(this.options.circle[i].radius) > radius) {
radius = Number(this.options.circle[i].radius)
}
}
this._radius = radius
inputElm.value = value
CircleDiffuse.create(this)
}
})
// 颜色组件
2025-07-16 15:02:18 +08:00
let colorPicker = new YJColorPicker({
2025-07-03 13:54:01 +08:00
el: circleElm.getElementsByClassName("color")[0],
size: 'mini',//颜色box类型
alpha: false,//是否开启透明度
2025-07-16 15:02:18 +08:00
defaultColor: this.options.circle[i].color || this.options.color,
2025-07-03 13:54:01 +08:00
disabled: false,//是否禁止打开颜色选择器
openPickerAni: 'opacity',//打开颜色选择器动画
sure: (color) => {
this.options.circle[i].color = color
CircleDiffuse.create(this)
},//点击确认按钮事件回调
clear: () => {
this.options.circle[i].color = 'rgba(255,255,255,1)'
CircleDiffuse.create(this)
},//点击清空按钮事件回调
})
// 减
let minusElm = circleElm.getElementsByClassName('circle-minus')[0]
minusElm && minusElm.addEventListener('click', () => {
this.options.circle.splice(i, 1)
let radius = 0
for (let i = 0; i < this.options.circle.length; i++) {
if (Number(this.options.circle[i].radius) > radius) {
radius = Number(this.options.circle[i].radius)
}
}
this._radius = radius
CircleDiffuse.create(this)
this._createCircleElm()
})
// 加
let addElm = circleElm.getElementsByClassName('circle-add')[0]
addElm && addElm.addEventListener('click', () => {
this.options.circle.push({
radius: 0,
color: 'rgba(255,255,255,1)'
})
let radius = 0
for (let i = 0; i < this.options.circle.length; i++) {
if (Number(this.options.circle[i].radius) > radius) {
radius = Number(this.options.circle[i].radius)
}
}
this._radius = radius
CircleDiffuse.create(this)
this._createCircleElm()
})
circleContentElm.appendChild(circleElm)
}
}
}
_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
}
}
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 siteInfoDom = document.getElementById(options.domid)
let siteInfoPosition = Cesium.Cartesian3.fromDegrees(this.options.lng, this.options.lat)
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 CircleDiffuse