This commit is contained in:
zh
2025-09-08 17:27:42 +08:00
parent b84a378ab9
commit d20db7c91b
7 changed files with 154 additions and 548 deletions

View File

@ -16,7 +16,7 @@ class Layer extends BaseLayer {
super(sdk, options)
this.object = {}
this.options.host = this.options.host || getHost()
this.on()
}
get type() {
@ -24,21 +24,7 @@ class Layer extends BaseLayer {
}
on() {
return this.add()
}
async add() {
let res = await this.requestResource()
let text = await res.text()
text = JSON.parse(text)
if ([0, 200].includes(text.code)) {
return this.loadLayer(text.data)
} else {
return new Promise((res, reject) => {
reject(text.msg || text.message)
})
}
return this.loadLayer(this.options)
}
async loadLayer(data) {
@ -64,11 +50,11 @@ class Layer extends BaseLayer {
Cesium.Math.toRadians(this.object.north)
),
}
// if (this.object.scheme_name === "GeographicTilingScheme") {
// if (this.object.schemaName === "GeographicTilingScheme") {
// console.log("添加GeographicTilingScheme")
// params.tilingScheme = new Cesium.GeographicTilingScheme()
// }
// if (this.object.scheme_name === "amapMercatorTilingScheme") {
// if (this.object.schemaName === "amapMercatorTilingScheme") {
// console.log("添加amapMercatorTilingScheme")
// params.tilingScheme = this.amapMercatorTilingScheme()
// }
@ -80,19 +66,19 @@ class Layer extends BaseLayer {
// } else {
// tms = new Cesium.UrlTemplateImageryProvider(params)
// }
switch (this.object.scheme_name) {
switch (this.object.schemaName) {
case "amapMercatorTilingScheme":
params.tilingScheme = this.amapMercatorTilingScheme()
break;
case "":
break;
default:
params.tilingScheme = new Cesium[this.object.scheme_name]()
params.tilingScheme = new Cesium[this.object.schemaName]()
break;
}
switch (this.object.load_method) {
case "tms":
if(this.object.url.endsWith("tilemapresource.xml")){
if (this.object.url.endsWith("tilemapresource.xml")) {
let arr = this.object.url.split("/")
arr.pop()
let url = arr.join("/")
@ -116,7 +102,7 @@ class Layer extends BaseLayer {
break;
}
if(!this.sdk || !this.sdk.viewer) {
if (!this.sdk || !this.sdk.viewer) {
return
}
if (this.options.hasOwnProperty("layer_index")) {
@ -137,7 +123,7 @@ class Layer extends BaseLayer {
this.alpha = this.options.alpha
this.brightness = this.options.brightness
if(this.options.show) {
if (this.options.show) {
setSplitDirection(0, this.options.id)
}
}

View File

@ -46,6 +46,7 @@ class BIM extends BaseTileset {
this.exportProperty(this.exportStateArray)
}
this.features = new Map()
this.on()
}
get type() {

View File

@ -32,6 +32,7 @@ class Tileset extends BaseTileset {
constructor(earth, options = {}, _Dialog = {}) {
super(earth, options)
this.picking = false
this.on()
this.Dialog = _Dialog
this._elms = {};
this._EventBinding = new EventBinding()
@ -42,7 +43,7 @@ class Tileset extends BaseTileset {
}
on() {
return this.add()
return this.loadTileset(this.options)
}
get name() {

View File

@ -74,31 +74,6 @@ class BaseTileset extends BaseSource {
this.editObj.controllerCallBack = this.rotationEditingCallBack
}
async add() {
if (this.options.url) {
return this.loadTileset({
url: this.options.url
})
} else {
let res = await this.requestResource()
let text = await res.text()
text = JSON.parse(text)
if ([0, 200].includes(text.code)) {
if (text.data.url.length)
return this.loadTileset(text.data)
else
return new Promise((res, reject) => {
reject('资源不存在')
})
} else {
return new Promise((res, reject) => {
reject(text.msg || text.message)
})
}
}
}
loadSceneTree() {
}
@ -469,7 +444,7 @@ class BaseTileset extends BaseSource {
on() {
return this.add()
return this.loadTileset(this.options)
}
setDefaultValue() {

View File

@ -33,7 +33,6 @@ class CircleObject extends Base {
* @param options.line.width=3 {number} 边框宽
* @param options.line.color="#ff000080" {string} 边框颜色
* @param options.heightMode=2{number} 高度模式0海拔高度1相对地表2依附模式
* @param options.areaUnit='平方米' {string} 面积单位
* @param options.customView {object} 默认视角
* @param options.customView.orientation {object} 默认视角方位
* @param options.customView.orientation.heading {number} 航向角
@ -87,7 +86,6 @@ class CircleObject extends Base {
this.options.line = options.line || {}
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
this.options['area-unit'] = options['area-unit'] || '平方米'
options.label = options.label || {}
this._elms = {};
this.options.label = {
@ -108,13 +106,13 @@ class CircleObject extends Base {
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.vr = this.options.attribute.vr || {}
this.options.attribute.vr.content = this.options.attribute.vr.content || []
this.options.attribute.camera = this.options.attribute.camera || {}
this.options.attribute.camera.content = this.options.attribute.camera.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'
delete this.options.attribute.camera
delete this.options.attribute.vr
delete this.options.attribute.goods
this.event = new MouseEvent(this.sdk)
this.nodePoints = []
this.operate = {}
@ -140,7 +138,7 @@ class CircleObject extends Base {
return
}
let heightModeName = ''
CircleObject.closeNodeEdit(this)
this.closeNodeEdit()
let ground = false
let disabled = false
this.renewPositions()
@ -330,45 +328,6 @@ class CircleObject extends Base {
})
}
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
}
@ -580,320 +539,6 @@ class CircleObject extends Base {
}
}
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 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 fromDegreesArray = that.createCircle(that.options.center, that.options.radius)
let ground
@ -914,9 +559,10 @@ class CircleObject extends Base {
ground = true
break
}
if (!that.options.label.position) {
that.options.label.position = { lng: that.options.center.lng, lat: that.options.center.lat, alt: that.options.center.alt + height }
}
// if (!that.options.label.position) {
// that.options.label.position = { lng: that.options.center.lng, lat: that.options.center.lat, alt: that.options.center.alt + height }
// }
that.options.label.position = { lng: that.options.center.lng, lat: that.options.center.lat, alt: that.options.center.alt + height }
let material = Cesium.Color.fromCssColorString(that.options.color)
if (that.sdk.viewer.scene.mode === 2) {
@ -930,7 +576,7 @@ class CircleObject extends Base {
for (let i = 0; i < fromDegreesArray.length; i += 2) {
fromDegreesArray2.push(fromDegreesArray[i], fromDegreesArray[i + 1], that.options.center.alt + height)
}
that.options.label.ground = ground
// that.options.label.ground = ground
that.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
positionsA = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
that.entity = that.sdk.viewer.entities.add({
@ -953,23 +599,8 @@ class CircleObject extends Base {
})
that.sdk._entityZIndex++
CircleObject.createLabel(that)
that.options.areaByMeter = Number((Cesium.Math.PI * that.options.radius * that.options.radius).toFixed(2));
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
}
that.areaByMeter = Number((Cesium.Math.PI * that.options.radius * that.options.radius).toFixed(2));
that.areaChangeCallBack && that.areaChangeCallBack()
syncData(that.sdk, that.options.id)
if (that.options.show) {
@ -995,12 +626,12 @@ class CircleObject extends Base {
scaleByDistance: that.options.label.scaleByDistance,
near: that.options.label.near,
far: that.options.label.far,
ground: that.options.label.ground,
})
}
// 编辑框
async edit(state) {
return
let _this = this
this.originalOptions = this.deepCopyObj(this.options)
@ -1492,8 +1123,6 @@ class CircleObject extends Base {
this.name = this.originalOptions.name
this.radius = this.originalOptions.radius
this.color = this.originalOptions.color
this.area = this.originalOptions.area
this.areaUnit = this.originalOptions['area-unit']
this.labelShow = this.originalOptions.label.show
this.labelFontSize = this.originalOptions.label.fontSize
this.labelFontFamily = this.originalOptions.label.fontFamily
@ -1509,12 +1138,6 @@ class CircleObject extends Base {
this.lineColor = this.originalOptions.line.color
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
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.cameraSelect && this.cameraSelect()
this.goodsSelect && this.goodsSelect()
this.heightMode = this.originalOptions.heightMode
@ -1554,51 +1177,6 @@ class CircleObject extends Base {
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({
name: '链接',
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({
name: '链接',
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({
name: '全景图' ,
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({
name: '全景图' ,
url: vr
})
this.attributeVr = this.options.attribute.vr.content
}
/**
* 飞到
*/
@ -1803,6 +1381,11 @@ class CircleObject extends Base {
positions: { ...this.options.center }
}
this.positionEditing = false
if(this._positionEditingCallback) {
this._positionEditingCallback()
this._positionEditingCallback = null
}
})
this.event.mouse_right((movement, cartesian) => {
this.positionEditing = false
@ -1866,88 +1449,104 @@ class CircleObject extends Base {
return this.operate.positionEditing
}
static nodeEdit(that, cb = () => { }) {
that.positionEditing = false
openPositionEditing(cd) {
this.positionEditing = true
this._positionEditingCallback = cd
}
get areaChangeCallBack() {
return this._areaChangeCallBack
}
set areaChangeCallBack (cd) {
this._areaChangeCallBack = cd
}
nodeEdit(cb = () => { }) {
this.positionEditing = false
if (YJ.Measure.GetMeasureStatus()) {
} else {
that.event && that.event.destroy()
that.event = new MouseEvent(that.sdk)
let _this = this
this.event && this.event.destroy()
this.event = new MouseEvent(this.sdk)
YJ.Measure.SetMeasureStatus(true)
that.tip = new MouseTip('左键确认,右键取消', that.sdk)
that.event = new MouseEvent(that.sdk)
that.nodePoints = []
this.tip = new MouseTip('左键确认,右键取消', this.sdk)
this.event = new MouseEvent(this.sdk)
this.nodePoints = []
let selectPoint
let originalPosition
let newpositions = []
let fromDegreesArray = []
let endpoint = { ...that.options.center }
let endpoint = { ...this.options.center }
let moveRadius = null
let entity
fromDegreesArray = that.createCircle(that.options.center, that.options.radius)
fromDegreesArray = this.createCircle(this.options.center, this.options.radius)
that.entity.polyline.clampToGround = true
that.entity.polyline.arcType = Cesium.ArcType.GEODESIC
that.entity.polygon.perPositionHeight = false
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
this.entity.polyline.clampToGround = true
this.entity.polyline.arcType = Cesium.ArcType.GEODESIC
this.entity.polygon.perPositionHeight = false
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
return new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray))
}, false)
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
}, false)
setTimeout(() => {
let objectsToExclude = [...that.sdk.viewer.entities.values]
that
let objectsToExclude = [...this.sdk.viewer.entities.values]
this
.getClampToHeight({
lng: that.options.center.lng,
lat: that.options.center.lat
lng: this.options.center.lng,
lat: this.options.center.lat
}, objectsToExclude)
.then(height => {
that.label.position = [
that.options.center.lng,
that.options.center.lat,
this.label.position = [
this.options.center.lng,
this.options.center.lat,
height
]
})
}, 50);
setTimeout(() => {
that.event.mouse_left((movement, cartesian) => {
this.event.mouse_left((movement, cartesian) => {
if (entity) {
that.sdk.viewer.entities.remove(entity)
this.sdk.viewer.entities.remove(entity)
entity = null
}
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
let radius = that.computeDistance2([that.options.center, endpoint])
that.radius = radius
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
let radius = this.computeDistance2([this.options.center, endpoint])
this.radius = radius
YJ.Measure.SetMeasureStatus(false)
that.event.destroy()
that.tip.destroy()
this.event.destroy()
this.tip.destroy()
that.heightMode = that.heightMode
this.heightMode = this.heightMode
cb('', {...this.options.center})
})
that.event.mouse_right((movement, cartesian) => {
this.event.mouse_right((movement, cartesian) => {
if (entity) {
that.sdk.viewer.entities.remove(entity)
this.sdk.viewer.entities.remove(entity)
entity = null
}
YJ.Measure.SetMeasureStatus(false)
that.event.destroy()
that.tip.destroy()
this.event.destroy()
this.tip.destroy()
that.heightMode = that.heightMode
this.heightMode = this.heightMode
})
that.event.mouse_move((movement, cartesian) => {
this.event.mouse_move((movement, cartesian) => {
entity && (entity.show = true)
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
moveRadius = that.computeDistance2([that.options.center, endpoint])
fromDegreesArray = that.createCircle(that.options.center, moveRadius)
that.tip.setPosition(
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
moveRadius = this.computeDistance2([this.options.center, endpoint])
fromDegreesArray = this.createCircle(this.options.center, moveRadius)
this.tip.setPosition(
cartesian,
movement.endPosition.x,
movement.endPosition.y
@ -1956,28 +1555,28 @@ class CircleObject extends Base {
createNodePoints()
}, 200);
async function createNodePoints() {
let objectsToExclude = [...that.sdk.viewer.entities.values]
let height = await that.getClampToHeight(that.options.center, objectsToExclude)
let entity = that.sdk.viewer.entities.add({
let objectsToExclude = [..._this.sdk.viewer.entities.values]
let height = await _this.getClampToHeight(_this.options.center, objectsToExclude)
let entity = _this.sdk.viewer.entities.add({
name: 'node-secondary-edit-point',
position: Cesium.Cartesian3.fromDegrees(that.options.center.lng, that.options.center.lat, height),
position: Cesium.Cartesian3.fromDegrees(_this.options.center.lng, _this.options.center.lat, height),
billboard: {
image: that.getSourceRootPath() + '/img/point.png',
image: _this.getSourceRootPath() + '/img/point.png',
width: 15,
height: 15,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
color: Cesium.Color.WHITE.withAlpha(0.99)
},
})
that.nodePoints.push(entity)
_this.nodePoints.push(entity)
}
entity = that.sdk.viewer.entities.add(
entity = this.sdk.viewer.entities.add(
new Cesium.Entity({
show: false,
position: new Cesium.CallbackProperty((e) => {
if (endpoint) {
let c = that.computeMidpoint(that.options.center, endpoint)
let c = this.computeMidpoint(this.options.center, endpoint)
return Cesium.Cartesian3.fromDegrees(c.lng, c.lat, endpoint.alt)
} else {
return Cesium.Cartesian3()
@ -2000,7 +1599,7 @@ class CircleObject extends Base {
},
polyline: {
positions: new Cesium.CallbackProperty((e) => {
return Cesium.Cartesian3.fromDegreesArray([that.options.center.lng, that.options.center.lat, endpoint.lng, endpoint.lat])
return Cesium.Cartesian3.fromDegreesArray([this.options.center.lng, this.options.center.lat, endpoint.lng, endpoint.lat])
}, false),
width: 2,
material:
@ -2010,22 +1609,22 @@ class CircleObject extends Base {
}
})
)
that.nodePoints.push(entity)
this.nodePoints.push(entity)
}
}
static closeNodeEdit(that) {
closeNodeEdit() {
YJ.Measure.SetMeasureStatus(false)
that.event && that.event.destroy()
that.tip && that.tip.destroy()
that.tip = null
this.event && this.event.destroy()
this.tip && this.tip.destroy()
this.tip = null
for (let i = 0; i < that.nodePoints.length; i++) {
that.sdk.viewer.entities.remove(that.nodePoints[i])
for (let i = 0; i < this.nodePoints.length; i++) {
this.sdk.viewer.entities.remove(this.nodePoints[i])
}
that.nodePoints = []
that.picking = true
this.nodePoints = []
this.picking = true
}
@ -2205,8 +1804,8 @@ class CircleObject extends Base {
}
// 计算投影面积
this.options.areaByMeter = Number((Cesium.Math.PI * this.options.radius * this.options.radius).toFixed(2))
this.areaUnit = this.areaUnit
this.areaByMeter = Number((Cesium.Math.PI * this.options.radius * this.options.radius).toFixed(2))
this.areaChangeCallBack && this.areaChangeCallBack()
return fromDegreesArray
}
}

View File

@ -30,6 +30,10 @@ class Base extends Tools {
this.rightClickCallBack = null
this.picking = true
this.options.host = this.options.host || getHost()
this.options.customView = options.customView ||{
relativePosition: undefined,
orientation: undefined
}
// this._showView = this.options.showView || 0
this.setDefaultValue()
this._showView
@ -501,7 +505,10 @@ class Base extends Tools {
// 重置视角
resetCustomView() {
this.options.customView = undefined
this.options.customView = {
relativePosition: undefined,
orientation: undefined
}
}

View File

@ -31,6 +31,8 @@ import YJColorPicker from "../Obj/Element/yj-color-picker";
class YJEarth {
#_requestAnimationFrameEventId = undefined
#_BillboardCollection
#_LabelCollection
/**
* @constructor
* @param div_id {string} 地球所在的dom id
@ -272,6 +274,34 @@ class YJEarth {
this.viewer.scene.fxaa = true
this.viewer.scene.postProcessStages.fxaa.enabled = true
this.viewer.scene.screenSpaceCameraController.enableCollisionDetection = true //true 禁止 false 允许
const BillboardCollection = this.viewer.scene.primitives.add(new Cesium.BillboardCollection({
scene: this.viewer.scene,
}));
const labelCollection = this.viewer.scene.primitives.add(new Cesium.LabelCollection({
scene: this.viewer.scene,
}));
this.#_BillboardCollection = BillboardCollection
this.#_LabelCollection = labelCollection
createCluster(this.viewer)
keyboardMapRoamingInit(this.viewer)
let a = Cesium.viewerCesiumNavigationMixin(this.viewer, {
@ -522,6 +552,13 @@ class YJEarth {
}
get collection() {
return {
billboard: this.#_BillboardCollection,
label: this.#_LabelCollection
}
}
destroy() {
cancelAnimationFrame(this.#_requestAnimationFrameEventId)
for (let [id, obj] of this.entityMap) {