解决二三维快速切换贴地svg显隐报错的问题

This commit is contained in:
zh
2025-07-18 16:49:42 +08:00
parent 72fc510167
commit f2a198ddaf
5 changed files with 79 additions and 6 deletions

View File

@ -108,12 +108,18 @@ class GroundSvg extends Base {
this._isdrag = false
this._EventBinding = new EventBinding()
if(this.sdk.entityMap.get(this.options.id)) {
return
}
this.sdk.addIncetance(this.options.id, this)
this.picking = true
if (this.options.show) {
setSplitDirection(0, this.options.id)
}
this._entityArray = []
this.init()
}
@ -157,8 +163,6 @@ class GroundSvg extends Base {
if (this.options.text && this.options.text.show && this.text) {
this.text.show = v
}
syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
} else {
console.error("参数必须为boolean")
}
@ -820,8 +824,13 @@ class GroundSvg extends Base {
}
for (let i = 0; i < this.hierarchys.length; i++) {
for (let m = 0; m < this.hierarchys[i].length; m++) {
let id = this.options.id + `-${i}_${m}}`
let oldEntity = this.sdk.viewer.entities.getById(id)
if(oldEntity) {
this.sdk.viewer.entities.remove(oldEntity)
}
let entity = this.sdk.viewer.entities.add({
id: this.options.id + `-${i}_${m}`,
id: this.options.id + `-${i}_${m}}`,
show: this.options.show,
polygon: {
hierarchy: new Cesium.CallbackProperty(() => {
@ -854,6 +863,7 @@ class GroundSvg extends Base {
color: this.geojson.features[i].properties.color
}
}
this._entityArray.push(entity)
this.entity.add(entity)
}
}
@ -1991,6 +2001,8 @@ class GroundSvg extends Base {
}
async remove() {
this._worker.onmessage = (event) => {}
await this.sdk.removeIncetance(this.options.id)
if (!this.entity) {
return
}
@ -2000,12 +2012,11 @@ class GroundSvg extends Base {
for (let i = this.entity.values.length; i >= 0; i--) {
this.sdk.viewer.entities.remove(this.entity.values[i])
}
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)
}

View File

@ -65,6 +65,11 @@ class LabelObject extends Base {
}
this.originalOptions = copyObj(this.options)
let id = this.options.id + '-label'
let oldEntity = this.sdk.viewer.entities.getById(id)
if(oldEntity) {
this.sdk.viewer.entities.remove(oldEntity)
}
this.entity = this.sdk.viewer.entities.add({
show: this.options.show,
id: this.options.id + '-label',

View File

@ -13,6 +13,7 @@ import MouseTip from '../../../MouseTip'
import Controller from '../../../Controller/index'
import { syncData } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist'
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
@ -82,6 +83,7 @@ class PolylineObject extends Base {
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
@ -693,6 +695,21 @@ class PolylineObject extends Base {
})
}
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
}
@ -1289,6 +1306,7 @@ class PolylineObject extends Base {
],
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,
@ -2147,6 +2165,37 @@ class PolylineObject extends Base {
this._elms.altInput.push(altInput)
tBodyElm.appendChild(tr)
}
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)
} else {
if (this._DialogObject && this._DialogObject.close) {
@ -2348,6 +2397,7 @@ class PolylineObject extends Base {
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.labelLineWidth = this.originalOptions.label.lineWidth
this.labelPixelOffset = this.originalOptions.label.pixelOffset
this.labelLineColor = this.originalOptions.label.lineColor

View File

@ -86,6 +86,13 @@ class YJColorPicker {
let pickPen = document.createElement('div')
pickPen.className = 'icon-pen-box'
pickPen.innerHTML = '<svg class="icon-pen"><use xlink:href="#yj-icon-pen"></use></svg>'
/** 为完成、暂时隐藏 *///////
pickPen.style.opacity = '0'
pickPen.style.cursor = 'unset'
let pickerInput = _this.colorPicker.pickerInput
pickerInput.parentNode.insertBefore(pickPen, pickerInput)
pickerInput.style.width = '188px'