Compare commits
3 Commits
9e439f5229
...
d20db7c91b
Author | SHA1 | Date | |
---|---|---|---|
d20db7c91b | |||
b84a378ab9 | |||
ae48dbd700 |
@ -28,7 +28,6 @@ class AssembleObject extends Base {
|
||||
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||
* @param options.height {number} 高度
|
||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||
* @param options.areaUnit='平方米' {string} 面积单位
|
||||
* @param options.line {object} 边框
|
||||
* @param options.line.width=2 {string} 边框宽
|
||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||
@ -80,7 +79,6 @@ class AssembleObject 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'] || '平方米'
|
||||
this.entity
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.operate = {}
|
||||
@ -105,13 +103,11 @@ class AssembleObject 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.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'
|
||||
|
||||
delete this.options.attribute.camera
|
||||
delete this.options.attribute.vr
|
||||
delete this.options.attribute.goods
|
||||
|
||||
this.nodePoints = []
|
||||
if (!this.options.positions || this.options.positions.length < 3) {
|
||||
this._error = '集结地最少需要三个坐标!'
|
||||
@ -189,7 +185,7 @@ class AssembleObject extends Base {
|
||||
return
|
||||
}
|
||||
let heightModeName = ''
|
||||
AssembleObject.closeNodeEdit(this)
|
||||
this.closeNodeEdit()
|
||||
let ground = false
|
||||
let disabled = false
|
||||
this.renewPositions()
|
||||
@ -314,45 +310,6 @@ class AssembleObject 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
|
||||
}
|
||||
@ -564,319 +521,6 @@ class AssembleObject 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 positions = that.options.positions
|
||||
let fromDegreesArray = []
|
||||
@ -919,9 +563,10 @@ class AssembleObject extends Base {
|
||||
break
|
||||
}
|
||||
|
||||
if (!that.options.label.position) {
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
}
|
||||
// if (!that.options.label.position) {
|
||||
// that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
// }
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
|
||||
let fromDegreesArray2 = []
|
||||
for (let i = 0; i < points[0].length; i++) {
|
||||
@ -939,7 +584,7 @@ class AssembleObject extends Base {
|
||||
color: that.options.color
|
||||
})
|
||||
}
|
||||
that.options.label.ground = ground
|
||||
// that.options.label.ground = ground
|
||||
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
||||
|
||||
that.entity = that.sdk.viewer.entities.add({
|
||||
@ -967,23 +612,8 @@ class AssembleObject extends Base {
|
||||
for (let i = 0; i < positionsA.length; i++) {
|
||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||
}
|
||||
that.options.areaByMeter = that.computeArea(pos84);
|
||||
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 = that.computeArea(pos84);
|
||||
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||
syncData(that.sdk, that.options.id)
|
||||
if (that.options.show) {
|
||||
setSplitDirection(0, that.options.id)
|
||||
@ -1007,12 +637,13 @@ class AssembleObject extends Base {
|
||||
scaleByDistance: that.options.label.scaleByDistance,
|
||||
near: that.options.label.near,
|
||||
far: that.options.label.far,
|
||||
ground: that.options.label.ground,
|
||||
// ground: that.options.label.ground,
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑框
|
||||
async edit(state) {
|
||||
return
|
||||
if (this._error) {
|
||||
return
|
||||
}
|
||||
@ -1446,7 +1077,6 @@ class AssembleObject extends Base {
|
||||
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)
|
||||
@ -1511,8 +1141,6 @@ class AssembleObject extends Base {
|
||||
this.color = this.originalOptions.color
|
||||
this.lineColor = this.originalOptions.line.color
|
||||
this.lineWidth = this.originalOptions.line.width
|
||||
this.area = this.originalOptions.area
|
||||
this.areaUnit = this.originalOptions['area-unit']
|
||||
this.labelShow = this.originalOptions.label.show
|
||||
this.labelColor = this.originalOptions.label.color
|
||||
this.labelFontSize = this.originalOptions.label.fontSize
|
||||
@ -1525,12 +1153,6 @@ class AssembleObject extends Base {
|
||||
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()
|
||||
|
||||
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
@ -1572,51 +1194,6 @@ class AssembleObject extends Base {
|
||||
await syncData(this.sdk, this.options.id)
|
||||
}
|
||||
|
||||
_addLink() {
|
||||
// document.getElementsByClassName
|
||||
if (this._DialogObject._element.content.getElementsByClassName('link_add')[0] && 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞到
|
||||
*/
|
||||
@ -1818,6 +1395,11 @@ class AssembleObject extends Base {
|
||||
this.positions = newpositions
|
||||
this.previous = null
|
||||
this.positionEditing = false
|
||||
|
||||
if(this._positionEditingCallback) {
|
||||
this._positionEditingCallback()
|
||||
this._positionEditingCallback = null
|
||||
}
|
||||
})
|
||||
this.event.mouse_right((movement, cartesian) => {
|
||||
this.positionEditing = false
|
||||
@ -1919,131 +1501,47 @@ class AssembleObject extends Base {
|
||||
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)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
openPositionEditing(cd) {
|
||||
this.positionEditing = true
|
||||
this._positionEditingCallback = cd
|
||||
}
|
||||
get areaChangeCallBack() {
|
||||
return this._areaChangeCallBack
|
||||
}
|
||||
|
||||
static nodeEdit(that, cb = () => { }) {
|
||||
that.positionEditing = false
|
||||
set areaChangeCallBack (cd) {
|
||||
this._areaChangeCallBack = cd
|
||||
}
|
||||
|
||||
nodeEdit(cb = () => { }) {
|
||||
this.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 _this = this
|
||||
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.nodePoints = []
|
||||
let selectPoint
|
||||
let originalPosition
|
||||
let fromDegreesArray = []
|
||||
for (let i = 0; i < that.options.positions.length; i++) {
|
||||
fromDegreesArray.push(that.options.positions[i].lng, that.options.positions[i].lat)
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
fromDegreesArray.push(this.options.positions[i].lng, this.options.positions[i].lat)
|
||||
}
|
||||
|
||||
let moveEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
}
|
||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
}
|
||||
that.renewPositions()
|
||||
this.renewPositions()
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.position ? movement.position.x : movement.endPosition.x,
|
||||
movement.position ? movement.position.y : movement.endPosition.y
|
||||
@ -2052,25 +1550,25 @@ class AssembleObject extends Base {
|
||||
|
||||
let leftEvent = (movement, cartesian) => {
|
||||
moveEvent(movement, cartesian)
|
||||
let position84 = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
let position84 = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
if (selectPoint) {
|
||||
let index = selectPoint.index
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let entity = this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: index,
|
||||
position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, position84.alt),
|
||||
position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, position84.alt),
|
||||
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.splice(selectPoint.index, 0, entity)
|
||||
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
selectPoint = null
|
||||
|
||||
that.tip.set_text('请选择一个顶点,右键取消')
|
||||
this.tip.set_text('请选择一个顶点,右键取消')
|
||||
}
|
||||
else {
|
||||
let position = movement.position
|
||||
@ -2080,49 +1578,50 @@ class AssembleObject extends Base {
|
||||
y: (movement.position1.y + movement.position2.y) / 2
|
||||
}
|
||||
}
|
||||
var pick = that.sdk.viewer.scene.pick(position);
|
||||
var pick = this.sdk.viewer.scene.pick(position);
|
||||
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||
selectPoint = pick.id
|
||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
||||
that.nodePoints.splice(pick.id.index, 1)
|
||||
that.sdk.viewer.entities.remove(pick.id)
|
||||
that.tip.set_text('左键确认,右键取消')
|
||||
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||
this.nodePoints.splice(pick.id.index, 1)
|
||||
this.sdk.viewer.entities.remove(pick.id)
|
||||
this.tip.set_text('左键确认,右键取消')
|
||||
}
|
||||
}
|
||||
that.renewPositions()
|
||||
this.renewPositions()
|
||||
cb('', [...this.options.positions])
|
||||
}
|
||||
let rightEvent = () => {
|
||||
that.event.mouse_move(() => { })
|
||||
that.event.mouse_left(() => { })
|
||||
that.event.mouse_right(() => { })
|
||||
that.event.gesture_pinck_start(() => { })
|
||||
this.event.mouse_move(() => { })
|
||||
this.event.mouse_left(() => { })
|
||||
this.event.mouse_right(() => { })
|
||||
this.event.gesture_pinck_start(() => { })
|
||||
if (selectPoint) {
|
||||
if (!originalPosition) {
|
||||
that.options.positions.pop()
|
||||
this.options.positions.pop()
|
||||
}
|
||||
else {
|
||||
that.options.positions[selectPoint.index] = originalPosition
|
||||
this.options.positions[selectPoint.index] = originalPosition
|
||||
}
|
||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
}
|
||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
}
|
||||
}
|
||||
that.heightMode = that.heightMode
|
||||
that.previous = null
|
||||
this.heightMode = this.heightMode
|
||||
this.previous = null
|
||||
}
|
||||
|
||||
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 () {
|
||||
let arr = that.computeAssemble(that.options.positions)
|
||||
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 () {
|
||||
let arr = _this.computeAssemble(_this.options.positions)
|
||||
return new Cesium.PolygonHierarchy(arr)
|
||||
}, false)
|
||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
let arr = that.computeAssemble(that.options.positions)
|
||||
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
let arr = _this.computeAssemble(_this.options.positions)
|
||||
if (arr.length >= 3) {
|
||||
return [...arr, arr[0], arr[1]]
|
||||
}
|
||||
@ -2134,23 +1633,23 @@ class AssembleObject extends Base {
|
||||
|
||||
let points = [[]]
|
||||
let pos84 = []
|
||||
for (let i = 0; i < that.positionsH.length; i++) {
|
||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
||||
for (let i = 0; i < this.positionsH.length; i++) {
|
||||
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||
pos84.push(position)
|
||||
points[0].push([position.lng, position.lat])
|
||||
}
|
||||
let position = that.cartesian3Towgs84(that.positionsH[0], that.sdk.viewer)
|
||||
let position = this.cartesian3Towgs84(this.positionsH[0], this.sdk.viewer)
|
||||
points[0].push([position.lng, position.lat])
|
||||
let polygon = turf.polygon(points)
|
||||
let centroid = turf.pointOnFeature(polygon)
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
that
|
||||
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||
this
|
||||
.getClampToHeight({
|
||||
lng: centroid.geometry.coordinates[0],
|
||||
lat: centroid.geometry.coordinates[1]
|
||||
}, objectsToExclude)
|
||||
.then(height => {
|
||||
that.label.position = [
|
||||
this.label.position = [
|
||||
centroid.geometry.coordinates[0],
|
||||
centroid.geometry.coordinates[1],
|
||||
height
|
||||
@ -2159,15 +1658,15 @@ class AssembleObject extends Base {
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
that.event.mouse_left(leftEvent)
|
||||
this.event.mouse_left(leftEvent)
|
||||
|
||||
that.event.mouse_right(rightEvent)
|
||||
this.event.mouse_right(rightEvent)
|
||||
|
||||
that.event.mouse_move(moveEvent)
|
||||
this.event.mouse_move(moveEvent)
|
||||
|
||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||
let startTime = new Date()
|
||||
that.event.gesture_pinck_end(() => {
|
||||
this.event.gesture_pinck_end(() => {
|
||||
let endTime = new Date()
|
||||
let pos = {
|
||||
position: {
|
||||
@ -2187,31 +1686,31 @@ class AssembleObject extends Base {
|
||||
createNodePoints()
|
||||
}, 200);
|
||||
async function createNodePoints() {
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
for (let i = 0; i < that.options.positions.length; i++) {
|
||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||
for (let i = 0; i < _this.options.positions.length; i++) {
|
||||
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||
let entity = _this.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),
|
||||
position: Cesium.Cartesian3.fromDegrees(_this.options.positions[i].lng, _this.options.positions[i].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)
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < that.options.positions.length; i++) {
|
||||
// let entity = that.sdk.viewer.entities.add({
|
||||
// for (let i = 0; i < this.options.positions.length; i++) {
|
||||
// let entity = this.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),
|
||||
// position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat),
|
||||
// billboard: {
|
||||
// image: that.getSourceRootPath() + '/img/point.png',
|
||||
// image: this.getSourceRootPath() + '/img/point.png',
|
||||
// width: 15,
|
||||
// height: 15,
|
||||
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
@ -2222,17 +1721,17 @@ class AssembleObject extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
setPosition(v) {
|
||||
@ -2323,7 +1822,7 @@ class AssembleObject extends Base {
|
||||
}
|
||||
|
||||
// 更新坐标
|
||||
renewPositions(position84) {
|
||||
renewPositions(position84, cd) {
|
||||
if (this._error || !this.sdk.viewer) {
|
||||
return
|
||||
}
|
||||
@ -2410,8 +1909,8 @@ class AssembleObject extends Base {
|
||||
}
|
||||
|
||||
// 计算投影面积
|
||||
this.options.areaByMeter = this.computeArea(pos84)
|
||||
this.areaUnit = this.areaUnit
|
||||
this.areaByMeter = this.computeArea(pos84)
|
||||
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||
return fromDegreesArray
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,6 @@ class AttackArrowObject 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'] || '平方米'
|
||||
this.entity
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.operate = {}
|
||||
@ -112,13 +111,11 @@ class AttackArrowObject 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.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'
|
||||
|
||||
delete this.options.attribute.camera
|
||||
delete this.options.attribute.vr
|
||||
delete this.options.attribute.goods
|
||||
|
||||
|
||||
if (!this.options.positions || this.options.positions.length < 3) {
|
||||
this._error = '箭头面最少需要三个坐标!'
|
||||
@ -196,7 +193,7 @@ class AttackArrowObject extends Base {
|
||||
return
|
||||
}
|
||||
let heightModeName = ''
|
||||
AttackArrowObject.closeNodeEdit(this)
|
||||
this.closeNodeEdit()
|
||||
let ground = false
|
||||
let disabled = false
|
||||
this.renewPositions()
|
||||
@ -322,45 +319,6 @@ class AttackArrowObject 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
|
||||
}
|
||||
@ -572,319 +530,6 @@ class AttackArrowObject 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 positions = that.options.positions
|
||||
let fromDegreesArray = []
|
||||
@ -928,10 +573,11 @@ class AttackArrowObject extends Base {
|
||||
break
|
||||
}
|
||||
|
||||
if (!that.options.label.position) {
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
}
|
||||
that.options.label.ground = ground
|
||||
// if (!that.options.label.position) {
|
||||
// that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
// }
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
// that.options.label.ground = ground
|
||||
|
||||
let fromDegreesArray2 = []
|
||||
for (let i = 0; i < points[0].length; i++) {
|
||||
@ -977,23 +623,8 @@ class AttackArrowObject extends Base {
|
||||
for (let i = 0; i < positionsA.length; i++) {
|
||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||
}
|
||||
that.options.areaByMeter = that.computeArea(pos84);
|
||||
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 = that.computeArea(pos84);
|
||||
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||
syncData(that.sdk, that.options.id)
|
||||
if (that.options.show) {
|
||||
|
||||
@ -1020,12 +651,13 @@ class AttackArrowObject extends Base {
|
||||
scaleByDistance: that.options.label.scaleByDistance,
|
||||
near: that.options.label.near,
|
||||
far: that.options.label.far,
|
||||
ground: that.options.label.ground,
|
||||
// ground: that.options.label.ground,
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑框
|
||||
async edit(state) {
|
||||
return
|
||||
if (this._error) {
|
||||
return
|
||||
}
|
||||
@ -1527,8 +1159,6 @@ class AttackArrowObject extends Base {
|
||||
this.color = this.originalOptions.color
|
||||
this.lineColor = this.originalOptions.line.color
|
||||
this.lineWidth = this.originalOptions.line.width
|
||||
this.area = this.originalOptions.area
|
||||
this.areaUnit = this.originalOptions['area-unit']
|
||||
this.labelShow = this.originalOptions.label.show
|
||||
this.labelColor = this.originalOptions.label.color
|
||||
this.labelFontSize = this.originalOptions.label.fontSize
|
||||
@ -1541,12 +1171,6 @@ class AttackArrowObject extends Base {
|
||||
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.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()
|
||||
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
if (this._elms.lng && this._elms.lng[i]) {
|
||||
@ -1597,51 +1221,6 @@ class AttackArrowObject extends Base {
|
||||
await syncData(this.sdk, this.options.id)
|
||||
}
|
||||
|
||||
_addLink() {
|
||||
// document.getElementsByClassName
|
||||
if (this._DialogObject._element.content.getElementsByClassName('link_add')[0] && 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞到
|
||||
*/
|
||||
@ -1747,16 +1326,6 @@ class AttackArrowObject extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开富文本框
|
||||
*/
|
||||
openRichTextEditor(e) {
|
||||
// var ue = UE.getEditor('app');
|
||||
richText.open(this.options.id, this.options.name, this.options.richTextContent)
|
||||
richText.primaryCallBack = (content) => {
|
||||
this.options.richTextContent = content
|
||||
}
|
||||
}
|
||||
|
||||
/**@desc 打开平移功能
|
||||
*
|
||||
@ -1844,6 +1413,11 @@ class AttackArrowObject extends Base {
|
||||
positions: [...this.positions]
|
||||
}
|
||||
this.positionEditing = false
|
||||
|
||||
if(this._positionEditingCallback) {
|
||||
this._positionEditingCallback()
|
||||
this._positionEditingCallback = null
|
||||
}
|
||||
})
|
||||
this.event.mouse_right((movement, cartesian) => {
|
||||
this.positionEditing = false
|
||||
@ -1946,6 +1520,18 @@ class AttackArrowObject extends Base {
|
||||
return this.operate.positionEditing
|
||||
}
|
||||
|
||||
openPositionEditing(cd) {
|
||||
this.positionEditing = true
|
||||
this._positionEditingCallback = cd
|
||||
}
|
||||
get areaChangeCallBack() {
|
||||
return this._areaChangeCallBack
|
||||
}
|
||||
|
||||
set areaChangeCallBack (cd) {
|
||||
this._areaChangeCallBack = cd
|
||||
}
|
||||
|
||||
static EventBinding(that, elements) {
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let Event = []
|
||||
@ -2045,28 +1631,29 @@ class AttackArrowObject extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
static nodeEdit(that, cb = () => { }) {
|
||||
that.positionEditing = false
|
||||
nodeEdit(cb = () => { }) {
|
||||
this.positionEditing = false
|
||||
setTimeout(() => {
|
||||
if (YJ.Measure.GetMeasureStatus()) {
|
||||
cb('上一次测量未结束')
|
||||
} else {
|
||||
that.removeAnimate()
|
||||
this.removeAnimate()
|
||||
YJ.Measure.SetMeasureStatus(true)
|
||||
that.event && that.event.destroy()
|
||||
that.tip && that.tip.destroy()
|
||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
||||
that.event = new MouseEvent(that.sdk)
|
||||
that.nodePoints = []
|
||||
let _this = this
|
||||
this.event && this.event.destroy()
|
||||
this.tip && this.tip.destroy()
|
||||
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.nodePoints = []
|
||||
let selectPoint
|
||||
let originalPosition
|
||||
|
||||
let moveEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
that.renewPositions()
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
this.renewPositions()
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.position ? movement.position.x : movement.endPosition.x,
|
||||
movement.position ? movement.position.y : movement.endPosition.y
|
||||
@ -2075,17 +1662,17 @@ class AttackArrowObject extends Base {
|
||||
let leftEvent = (movement, cartesian) => {
|
||||
moveEvent(movement, cartesian)
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
let index = selectPoint.index
|
||||
if (selectPoint.index === that.options.positions.length - 1) {
|
||||
if (selectPoint.index === this.options.positions.length - 1) {
|
||||
index = index + 1
|
||||
}
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let entity = this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: index,
|
||||
position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, that.options.positions[selectPoint.index].alt),
|
||||
position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, this.options.positions[selectPoint.index].alt),
|
||||
billboard: {
|
||||
image: that.getSourceRootPath() + '/img/point.png',
|
||||
image: this.getSourceRootPath() + '/img/point.png',
|
||||
width: 15,
|
||||
height: 15,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
@ -2094,86 +1681,87 @@ class AttackArrowObject extends Base {
|
||||
})
|
||||
selectPoint = entity
|
||||
|
||||
originalPosition = that.options.positions[selectPoint.index]
|
||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
originalPosition = this.options.positions[selectPoint.index]
|
||||
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
|
||||
if (index < that.options.positions.length) {
|
||||
if (index < this.options.positions.length) {
|
||||
selectPoint = null
|
||||
that.tip.set_text('请选择一个顶点,右键取消')
|
||||
this.tip.set_text('请选择一个顶点,右键取消')
|
||||
}
|
||||
else {
|
||||
that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index])
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index])
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
}
|
||||
that.renewPositions()
|
||||
this.renewPositions()
|
||||
cb('', [...this.options.positions])
|
||||
}
|
||||
else {
|
||||
var pick = that.sdk.viewer.scene.pick(movement.position || movement.endPosition);
|
||||
var pick = this.sdk.viewer.scene.pick(movement.position || movement.endPosition);
|
||||
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||
selectPoint = pick.id
|
||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
||||
that.nodePoints.splice(pick.id.index, 1)
|
||||
that.sdk.viewer.entities.remove(pick.id)
|
||||
that.tip.set_text('左键确认,右键结束,CTRL+右键撤销')
|
||||
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||
this.nodePoints.splice(pick.id.index, 1)
|
||||
this.sdk.viewer.entities.remove(pick.id)
|
||||
this.tip.set_text('左键确认,右键结束,CTRL+右键撤销')
|
||||
}
|
||||
}
|
||||
}
|
||||
let rightEvent = (movement, cartesian) => {
|
||||
that.event.mouse_move(() => { })
|
||||
that.event.mouse_left(() => { })
|
||||
that.event.mouse_right(() => { })
|
||||
that.event.gesture_pinck_start(() => { })
|
||||
this.event.mouse_move(() => { })
|
||||
this.event.mouse_left(() => { })
|
||||
this.event.mouse_right(() => { })
|
||||
this.event.gesture_pinck_start(() => { })
|
||||
if (selectPoint) {
|
||||
if (!originalPosition) {
|
||||
that.options.positions.pop()
|
||||
this.options.positions.pop()
|
||||
}
|
||||
else {
|
||||
that.options.positions[selectPoint.index] = originalPosition
|
||||
if (that.options.positions.length > 3 && selectPoint.index === that.options.positions.length - 1) {
|
||||
that.options.positions.splice(selectPoint.index + 1, 1)
|
||||
this.options.positions[selectPoint.index] = originalPosition
|
||||
if (this.options.positions.length > 3 && selectPoint.index === this.options.positions.length - 1) {
|
||||
this.options.positions.splice(selectPoint.index + 1, 1)
|
||||
}
|
||||
}
|
||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
}
|
||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
}
|
||||
}
|
||||
that.heightMode = that.heightMode
|
||||
that.previous = null
|
||||
this.heightMode = this.heightMode
|
||||
this.previous = null
|
||||
}
|
||||
|
||||
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 () {
|
||||
return new Cesium.PolygonHierarchy(that.positionsH)
|
||||
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(_this.positionsH)
|
||||
}, false)
|
||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
return [...that.positionsH, that.positionsH[0], that.positionsH[1]]
|
||||
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
return [..._this.positionsH, _this.positionsH[0], _this.positionsH[1]]
|
||||
}, false)
|
||||
|
||||
|
||||
let points = [[]]
|
||||
let pos84 = []
|
||||
for (let i = 0; i < that.positionsH.length; i++) {
|
||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
||||
for (let i = 0; i < this.positionsH.length; i++) {
|
||||
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||
pos84.push(position)
|
||||
points[0].push([position.lng, position.lat])
|
||||
}
|
||||
let position = that.cartesian3Towgs84(that.positionsH[0], that.sdk.viewer)
|
||||
let position = this.cartesian3Towgs84(this.positionsH[0], this.sdk.viewer)
|
||||
points[0].push([position.lng, position.lat])
|
||||
let polygon = turf.polygon(points)
|
||||
let centroid = turf.pointOnFeature(polygon)
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
that
|
||||
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||
this
|
||||
.getClampToHeight({
|
||||
lng: centroid.geometry.coordinates[0],
|
||||
lat: centroid.geometry.coordinates[1]
|
||||
}, objectsToExclude)
|
||||
.then(height => {
|
||||
that.label.position = [
|
||||
this.label.position = [
|
||||
centroid.geometry.coordinates[0],
|
||||
centroid.geometry.coordinates[1],
|
||||
height
|
||||
@ -2181,36 +1769,36 @@ class AttackArrowObject extends Base {
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
that.event.mouse_left(leftEvent)
|
||||
this.event.mouse_left(leftEvent)
|
||||
|
||||
that.event.mouse_right(rightEvent)
|
||||
this.event.mouse_right(rightEvent)
|
||||
|
||||
that.event.mouse_move(moveEvent)
|
||||
this.event.mouse_move(moveEvent)
|
||||
|
||||
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||
this.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()
|
||||
this.options.positions.pop()
|
||||
this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1])
|
||||
this.nodePoints.pop()
|
||||
if (!selectPoint.index) {
|
||||
// selectPoint = null
|
||||
}
|
||||
else if (selectPoint.index === that.options.positions.length) {
|
||||
if (that.nodePoints[selectPoint.index - 1]) {
|
||||
selectPoint = that.nodePoints[selectPoint.index - 1]
|
||||
else if (selectPoint.index === this.options.positions.length) {
|
||||
if (this.nodePoints[selectPoint.index - 1]) {
|
||||
selectPoint = this.nodePoints[selectPoint.index - 1]
|
||||
}
|
||||
else {
|
||||
selectPoint.index = selectPoint.index - 1
|
||||
}
|
||||
}
|
||||
|
||||
that.renewPositions()
|
||||
this.renewPositions()
|
||||
}
|
||||
})
|
||||
|
||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||
let startTime = new Date()
|
||||
that.event.gesture_pinck_end(() => {
|
||||
this.event.gesture_pinck_end(() => {
|
||||
let endTime = new Date()
|
||||
let pos = {
|
||||
position: {
|
||||
@ -2230,31 +1818,31 @@ class AttackArrowObject extends Base {
|
||||
createNodePoints()
|
||||
}, 200);
|
||||
async function createNodePoints() {
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
for (let i = 0; i < that.options.positions.length; i++) {
|
||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||
for (let i = 0; i < _this.options.positions.length; i++) {
|
||||
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||
let entity = _this.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),
|
||||
position: Cesium.Cartesian3.fromDegrees(_this.options.positions[i].lng, _this.options.positions[i].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)
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < that.options.positions.length; i++) {
|
||||
// let entity = that.sdk.viewer.entities.add({
|
||||
// for (let i = 0; i < this.options.positions.length; i++) {
|
||||
// let entity = this.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),
|
||||
// position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat),
|
||||
// billboard: {
|
||||
// image: that.getSourceRootPath() + '/img/point.png',
|
||||
// image: this.getSourceRootPath() + '/img/point.png',
|
||||
// width: 15,
|
||||
// height: 15,
|
||||
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
@ -2266,17 +1854,17 @@ class AttackArrowObject extends Base {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
setPosition(v) {
|
||||
@ -2679,8 +2267,8 @@ class AttackArrowObject extends Base {
|
||||
|
||||
// 计算投影面积
|
||||
if (!this.spreadState) {
|
||||
this.options.areaByMeter = this.computeArea(pos84)
|
||||
this.areaUnit = this.areaUnit
|
||||
this.areaByMeter = this.computeArea(pos84)
|
||||
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||
}
|
||||
return fromDegreesArray
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ class BIM extends BaseTileset {
|
||||
this.exportProperty(this.exportStateArray)
|
||||
}
|
||||
this.features = new Map()
|
||||
this.on()
|
||||
}
|
||||
|
||||
get type() {
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,12 +13,11 @@ import {
|
||||
} from '../../../Global/cluster/cluster'
|
||||
|
||||
class LabelObject extends Base {
|
||||
#updateBillboardImageTimeout
|
||||
#canvas = document.createElement('canvas')
|
||||
#canvas2 = document.createElement('canvas')
|
||||
constructor(sdk, options = {}, model) {
|
||||
super(sdk, options)
|
||||
this.model = model
|
||||
this._canvas = document.createElement('canvas')
|
||||
this._canvas2 = document.createElement('canvas')
|
||||
this.options.near = options.near || options.near === 0 ? options.near : 2000
|
||||
this.options.far = options.far || options.far === 0 ? options.far : 100000
|
||||
this.options.scaleByDistance = options.scaleByDistance || false
|
||||
@ -69,7 +68,7 @@ class LabelObject extends Base {
|
||||
|
||||
let id = this.options.id + '-label'
|
||||
let oldEntity = this.sdk.viewer.entities.getById(id)
|
||||
if(oldEntity) {
|
||||
if (oldEntity) {
|
||||
this.sdk.viewer.entities.remove(oldEntity)
|
||||
}
|
||||
this.entity = this.sdk.viewer.entities.add({
|
||||
@ -492,8 +491,8 @@ class LabelObject extends Base {
|
||||
// }
|
||||
|
||||
getcanvas() {
|
||||
const ctx = this.#canvas.getContext('2d')
|
||||
ctx.clearRect(0, 0, this.#canvas.width, this.#canvas.height);
|
||||
const ctx = this._canvas.getContext('2d')
|
||||
ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
|
||||
ctx.font = this.options.fontSize + 'px ' + this.font
|
||||
let texts = this.options.text.split('\n')
|
||||
let canvasWidth = 0
|
||||
@ -511,8 +510,8 @@ class LabelObject extends Base {
|
||||
if (canvasWidth < this.options.lineWidth) {
|
||||
canvasWidth = this.options.lineWidth
|
||||
}
|
||||
this.#canvas.width = canvasWidth
|
||||
this.#canvas.height = this.options.pixelOffset + canvasHeight
|
||||
this._canvas.width = canvasWidth
|
||||
this._canvas.height = this.options.pixelOffset + canvasHeight
|
||||
const linearGradient = ctx.createLinearGradient(
|
||||
0,
|
||||
0,
|
||||
@ -559,14 +558,14 @@ class LabelObject extends Base {
|
||||
ctx.stroke()
|
||||
ctx.closePath()
|
||||
|
||||
const ctx2 = this.#canvas2.getContext('2d')
|
||||
this.#canvas2.width = this.#canvas.width + 10
|
||||
this.#canvas2.height = this.#canvas.height + 10
|
||||
ctx2.drawImage(this.#canvas, 5, 5);
|
||||
const ctx2 = this._canvas2.getContext('2d')
|
||||
this._canvas2.width = this._canvas.width + 10
|
||||
this._canvas2.height = this._canvas.height + 10
|
||||
ctx2.drawImage(this._canvas, 5, 5);
|
||||
|
||||
// const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
// ctx.putImageData(imageData, 40, 40);
|
||||
return this.#canvas2.toDataURL("image/png")
|
||||
return this._canvas2.toDataURL("image/png")
|
||||
}
|
||||
|
||||
remove() {
|
||||
|
@ -28,7 +28,6 @@ class PincerArrowObject extends Base {
|
||||
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||
* @param options.height {number} 高度
|
||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||
* @param options.areaUnit='平方米' {string} 面积单位
|
||||
* @param options.line {object} 边框
|
||||
* @param options.line.width=2 {string} 边框宽
|
||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||
@ -83,7 +82,6 @@ class PincerArrowObject 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'] || '平方米'
|
||||
this.options.height = options.height
|
||||
this.options.loop = options.loop || false
|
||||
this.options.spreadState = options.spreadState || false
|
||||
@ -113,13 +111,10 @@ class PincerArrowObject 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.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'
|
||||
|
||||
delete this.options.attribute.camera
|
||||
delete this.options.attribute.vr
|
||||
delete this.options.attribute.goods
|
||||
|
||||
if (!this.options.positions || this.options.positions.length < 5) {
|
||||
this._error = '双箭头最少需要五个坐标!'
|
||||
@ -208,7 +203,7 @@ class PincerArrowObject extends Base {
|
||||
return
|
||||
}
|
||||
let heightModeName = ''
|
||||
PincerArrowObject.closeNodeEdit(this)
|
||||
this.closeNodeEdit()
|
||||
let ground = false
|
||||
let disabled = false
|
||||
this.renewPositions()
|
||||
@ -332,45 +327,6 @@ class PincerArrowObject 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
|
||||
}
|
||||
@ -582,320 +538,6 @@ class PincerArrowObject 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 positions = that.options.positions
|
||||
let fromDegreesArray = []
|
||||
@ -939,9 +581,10 @@ class PincerArrowObject extends Base {
|
||||
break
|
||||
}
|
||||
|
||||
if (!that.options.label.position) {
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
}
|
||||
// if (!that.options.label.position) {
|
||||
// that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
// }
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
|
||||
let fromDegreesArray2 = []
|
||||
for (let i = 0; i < points[0].length; i++) {
|
||||
@ -959,7 +602,7 @@ class PincerArrowObject extends Base {
|
||||
color: that.options.color
|
||||
})
|
||||
}
|
||||
that.options.label.ground = ground
|
||||
// that.options.label.ground = ground
|
||||
|
||||
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
||||
|
||||
@ -987,23 +630,8 @@ class PincerArrowObject extends Base {
|
||||
for (let i = 0; i < positionsA.length; i++) {
|
||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||
}
|
||||
that.options.areaByMeter = that.computeArea(pos84);
|
||||
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 = that.computeArea(pos84);
|
||||
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||
syncData(that.sdk, that.options.id)
|
||||
if (that.options.show) {
|
||||
|
||||
@ -1030,12 +658,13 @@ class PincerArrowObject extends Base {
|
||||
scaleByDistance: that.options.label.scaleByDistance,
|
||||
near: that.options.label.near,
|
||||
far: that.options.label.far,
|
||||
ground: that.options.label.ground,
|
||||
// ground: that.options.label.ground,
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑框
|
||||
async edit(state) {
|
||||
return
|
||||
if (this._error) {
|
||||
return
|
||||
}
|
||||
@ -1534,8 +1163,6 @@ class PincerArrowObject extends Base {
|
||||
this.color = this.originalOptions.color
|
||||
this.lineColor = this.originalOptions.line.color
|
||||
this.lineWidth = this.originalOptions.line.width
|
||||
this.area = this.originalOptions.area
|
||||
this.areaUnit = this.originalOptions['area-unit']
|
||||
this.labelShow = this.originalOptions.label.show
|
||||
this.labelColor = this.originalOptions.label.color
|
||||
this.labelFontSize = this.originalOptions.label.fontSize
|
||||
@ -1548,12 +1175,7 @@ class PincerArrowObject extends Base {
|
||||
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.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()
|
||||
|
||||
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
if (this._elms.lng && this._elms.lng[i]) {
|
||||
@ -1607,51 +1229,6 @@ class PincerArrowObject 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞到
|
||||
*/
|
||||
@ -1852,6 +1429,11 @@ class PincerArrowObject extends Base {
|
||||
positions: [...this.positions]
|
||||
}
|
||||
this.positionEditing = false
|
||||
|
||||
if(this._positionEditingCallback) {
|
||||
this._positionEditingCallback()
|
||||
this._positionEditingCallback = null
|
||||
}
|
||||
})
|
||||
this.event.mouse_right((movement, cartesian) => {
|
||||
this.positionEditing = false
|
||||
@ -1954,208 +1536,122 @@ class PincerArrowObject extends Base {
|
||||
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'
|
||||
}
|
||||
if (elements[i].className.indexOf('blur') !== -1) {
|
||||
ventType = 'blur'
|
||||
}
|
||||
elements[i].addEventListener(ventType, (e) => {
|
||||
for (let t = 0; t < Event.length; t++) {
|
||||
Event[t](e)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
openPositionEditing(cd) {
|
||||
this.positionEditing = true
|
||||
this._positionEditingCallback = cd
|
||||
}
|
||||
get areaChangeCallBack() {
|
||||
return this._areaChangeCallBack
|
||||
}
|
||||
|
||||
static nodeEdit(that, cb = () => { }) {
|
||||
that.positionEditing = false
|
||||
set areaChangeCallBack (cd) {
|
||||
this._areaChangeCallBack = cd
|
||||
}
|
||||
|
||||
|
||||
nodeEdit(cb = () => { }) {
|
||||
this.positionEditing = false
|
||||
setTimeout(() => {
|
||||
if (YJ.Measure.GetMeasureStatus()) {
|
||||
cb('上一次测量未结束')
|
||||
} else {
|
||||
that.removeAnimate()
|
||||
this.removeAnimate()
|
||||
let _this = this
|
||||
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 optionsPositions = [...that.options.positions]
|
||||
let optionsPositions = [...this.options.positions]
|
||||
|
||||
let leftEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
optionsPositions[selectPoint.index] = that.options.positions[selectPoint.index]
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
optionsPositions[selectPoint.index] = this.options.positions[selectPoint.index]
|
||||
let index = selectPoint.index
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let entity = this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: index,
|
||||
position: Cesium.Cartesian3.fromDegrees(optionsPositions[selectPoint.index].lng, optionsPositions[selectPoint.index].lat, optionsPositions[selectPoint.index].alt),
|
||||
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.splice(selectPoint.index, 0, entity)
|
||||
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
selectPoint = null
|
||||
that.tip.set_text('请选择一个顶点,右键取消')
|
||||
this.tip.set_text('请选择一个顶点,右键取消')
|
||||
}
|
||||
else {
|
||||
var pick = that.sdk.viewer.scene.pick(movement.position);
|
||||
var pick = this.sdk.viewer.scene.pick(movement.position);
|
||||
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||
selectPoint = pick.id
|
||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
||||
that.nodePoints.splice(pick.id.index, 1)
|
||||
that.sdk.viewer.entities.remove(pick.id)
|
||||
that.tip.set_text('左键确定,右键取消')
|
||||
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||
this.nodePoints.splice(pick.id.index, 1)
|
||||
this.sdk.viewer.entities.remove(pick.id)
|
||||
this.tip.set_text('左键确定,右键取消')
|
||||
}
|
||||
}
|
||||
that.renewPositions()
|
||||
that.tip.setPosition(
|
||||
this.renewPositions()
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.position.x,
|
||||
movement.position.y
|
||||
)
|
||||
}
|
||||
let rightEvent = () => {
|
||||
that.event.mouse_move(() => { })
|
||||
that.event.mouse_left(() => { })
|
||||
that.event.mouse_right(() => { })
|
||||
that.event.gesture_pinck_start(() => { })
|
||||
this.event.mouse_move(() => { })
|
||||
this.event.mouse_left(() => { })
|
||||
this.event.mouse_right(() => { })
|
||||
this.event.gesture_pinck_start(() => { })
|
||||
if (selectPoint) {
|
||||
optionsPositions[selectPoint.index] = originalPosition
|
||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
}
|
||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
}
|
||||
cb(null, optionsPositions)
|
||||
}
|
||||
that.options.positions = [...optionsPositions]
|
||||
that.heightMode = that.heightMode
|
||||
that.previous = null
|
||||
this.options.positions = [...optionsPositions]
|
||||
this.heightMode = this.heightMode
|
||||
this.previous = null
|
||||
}
|
||||
|
||||
|
||||
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 () {
|
||||
return new Cesium.PolygonHierarchy(that.positionsH)
|
||||
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(_this.positionsH)
|
||||
}, false)
|
||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
return [...that.positionsH, that.positionsH[0], that.positionsH[1]]
|
||||
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
return [..._this.positionsH, _this.positionsH[0], _this.positionsH[1]]
|
||||
}, false)
|
||||
|
||||
setTimeout(() => {
|
||||
that.event.mouse_left(leftEvent)
|
||||
this.event.mouse_left(leftEvent)
|
||||
|
||||
that.event.mouse_right(rightEvent)
|
||||
this.event.mouse_right(rightEvent)
|
||||
|
||||
that.event.mouse_move((movement, cartesian) => {
|
||||
this.event.mouse_move((movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
that.renewPositions()
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
this.renewPositions()
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.endPosition.x,
|
||||
movement.endPosition.y
|
||||
)
|
||||
})
|
||||
|
||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||
let startTime = new Date()
|
||||
let pos = {
|
||||
position: {
|
||||
@ -2163,7 +1659,7 @@ class PincerArrowObject extends Base {
|
||||
y: (movement.position1.y + movement.position2.y) / 2
|
||||
}
|
||||
}
|
||||
that.event.gesture_pinck_end(() => {
|
||||
this.event.gesture_pinck_end(() => {
|
||||
let endTime = new Date()
|
||||
if (endTime - startTime >= 500) {
|
||||
// 长按取消
|
||||
@ -2178,23 +1674,23 @@ class PincerArrowObject extends Base {
|
||||
|
||||
let points = [[]]
|
||||
let pos84 = []
|
||||
for (let i = 0; i < that.positionsH.length; i++) {
|
||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
||||
for (let i = 0; i < this.positionsH.length; i++) {
|
||||
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||
pos84.push(position)
|
||||
points[0].push([position.lng, position.lat])
|
||||
}
|
||||
let position = that.cartesian3Towgs84(that.positionsH[0], that.sdk.viewer)
|
||||
let position = this.cartesian3Towgs84(this.positionsH[0], this.sdk.viewer)
|
||||
points[0].push([position.lng, position.lat])
|
||||
let polygon = turf.polygon(points)
|
||||
let centroid = turf.pointOnFeature(polygon)
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
that
|
||||
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||
this
|
||||
.getClampToHeight({
|
||||
lng: centroid.geometry.coordinates[0],
|
||||
lat: centroid.geometry.coordinates[1]
|
||||
}, objectsToExclude)
|
||||
.then(height => {
|
||||
that.label.position = [
|
||||
this.label.position = [
|
||||
centroid.geometry.coordinates[0],
|
||||
centroid.geometry.coordinates[1],
|
||||
height
|
||||
@ -2203,39 +1699,39 @@ class PincerArrowObject extends Base {
|
||||
createNodePoints()
|
||||
}, 200);
|
||||
async function createNodePoints() {
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||
for (let i = 0; i < optionsPositions.length; i++) {
|
||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||
let entity = _this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: i,
|
||||
position: Cesium.Cartesian3.fromDegrees(optionsPositions[i].lng, optionsPositions[i].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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
setPosition(v) {
|
||||
@ -2673,8 +2169,8 @@ class PincerArrowObject extends Base {
|
||||
|
||||
// 计算投影面积
|
||||
if (!this.spreadState) {
|
||||
this.options.areaByMeter = this.computeArea(pos84)
|
||||
this.areaUnit = this.areaUnit
|
||||
this.areaByMeter = this.computeArea(pos84)
|
||||
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||
}
|
||||
return fromDegreesArray
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,7 @@ class GroundText extends Base {
|
||||
* @param options.id {string} 唯一标识
|
||||
* @param options.show=true {boolean} 显示/隐藏
|
||||
* @param options.text {string} 文字
|
||||
* @param options.color=#FFC107 {string} 颜色
|
||||
* @param options.angle=0 {number} 旋转角度
|
||||
* @param options.scale=1 {number} 缩放比例
|
||||
* @param options.speed=1 {number} 文字滚动速度
|
||||
@ -49,20 +50,21 @@ class GroundText extends Base {
|
||||
textArray.splice(70 - textArray.length)
|
||||
}
|
||||
this.options.text = textArray.join('\n')
|
||||
this.options.name = this.options.text
|
||||
this.options.show =
|
||||
options.show || options.show === false ? options.show : true
|
||||
this.options.angle = options.angle || 0
|
||||
this.options.scale =
|
||||
options.scale || options.scale === 0 ? options.scale : 1
|
||||
this.options.fontSize = options.fontSize || 20
|
||||
this.options.duration =
|
||||
options.duration || options.duration === 0 ? options.duration : 50000
|
||||
// this.options.fontSize = options.fontSize || 20
|
||||
// this.options.duration =
|
||||
// options.duration || options.duration === 0 ? options.duration : 50000
|
||||
this.options.speed =
|
||||
options.speed || options.speed === 0 ? options.speed : 1
|
||||
this.options.color = options.color || '#FFC107'
|
||||
this.options.position = options.position
|
||||
|
||||
delete this.options.name
|
||||
|
||||
if (!this.options.position && this.options.positions) {
|
||||
this.options.position = { lng: (this.options.positions[0].lng + this.options.positions[1].lng) / 2, lat: (this.options.positions[0].lat + this.options.positions[1].lat) / 2 }
|
||||
let point1 = turf.point([this.options.positions[0].lng, this.options.positions[0].lat]);
|
||||
@ -80,7 +82,7 @@ class GroundText extends Base {
|
||||
}
|
||||
|
||||
let angleRadians = calculateAngle([this.options.positions[0].lng, this.options.positions[0].lat], [this.options.positions[1].lng, this.options.positions[1].lat]);
|
||||
this.options.angle = (360+Cesium.Math.toDegrees(angleRadians))%360
|
||||
this.options.angle = (360 + Cesium.Math.toDegrees(angleRadians)) % 360
|
||||
|
||||
let gap =
|
||||
Math.abs(Math.cos((Math.PI / 180) * this.options.position.lat)) *
|
||||
@ -98,10 +100,11 @@ class GroundText extends Base {
|
||||
let to = turf.point([lng2, lat]);
|
||||
let distance2 = turf.rhumbDistance(from, to, options);
|
||||
let latRadians = Cesium.Math.toRadians(this.options.position.lat)
|
||||
distance2 = distance2 * (1+(Math.abs(Math.sin(angleRadians)*Math.tan(latRadians)*Math.sin(latRadians)*Math.sin(latRadians))))
|
||||
distance2 = distance2 * (1 + (Math.abs(Math.sin(angleRadians) * Math.tan(latRadians) * Math.sin(latRadians) * Math.sin(latRadians))))
|
||||
this.options.scale = distance1 / distance2
|
||||
}
|
||||
|
||||
this.duration = 50000
|
||||
this.entity
|
||||
this._positionEditing = false
|
||||
this.Dialog = _Dialog
|
||||
@ -137,6 +140,9 @@ class GroundText extends Base {
|
||||
})
|
||||
}
|
||||
|
||||
get name() {
|
||||
return
|
||||
}
|
||||
get text() {
|
||||
return this.options.text
|
||||
}
|
||||
@ -172,7 +178,7 @@ class GroundText extends Base {
|
||||
image: canvas.toDataURL('image/png'),
|
||||
color: this.options.color,
|
||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||
duration: this.options.duration / this.options.speed,
|
||||
duration: this.duration / this.options.speed,
|
||||
fltr: false,
|
||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||
})
|
||||
@ -219,26 +225,26 @@ class GroundText extends Base {
|
||||
})
|
||||
}
|
||||
|
||||
get duration() {
|
||||
return this.options.duration
|
||||
}
|
||||
// get duration() {
|
||||
// return this.options.duration
|
||||
// }
|
||||
|
||||
set duration(v) {
|
||||
this.options.duration = v
|
||||
let canvas = this.getcanvas()
|
||||
this.entity.rectangle.material = new Cesium.CustomMaterialSource({
|
||||
image: canvas.toDataURL('image/png'),
|
||||
color: this.options.color,
|
||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||
duration: this.options.duration / this.options.speed,
|
||||
fltr: false,
|
||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||
})
|
||||
this._elms.duration &&
|
||||
this._elms.duration.forEach(item => {
|
||||
item.value = v
|
||||
})
|
||||
}
|
||||
// set duration(v) {
|
||||
// this.options.duration = v
|
||||
// let canvas = this.getcanvas()
|
||||
// this.entity.rectangle.material = new Cesium.CustomMaterialSource({
|
||||
// image: canvas.toDataURL('image/png'),
|
||||
// color: this.options.color,
|
||||
// repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||
// duration: this.options.duration / this.options.speed,
|
||||
// fltr: false,
|
||||
// is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||
// })
|
||||
// this._elms.duration &&
|
||||
// this._elms.duration.forEach(item => {
|
||||
// item.value = v
|
||||
// })
|
||||
// }
|
||||
get speed() {
|
||||
return this.options.speed
|
||||
}
|
||||
@ -250,7 +256,7 @@ class GroundText extends Base {
|
||||
image: canvas.toDataURL('image/png'),
|
||||
color: this.options.color,
|
||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||
duration: this.options.duration / this.options.speed,
|
||||
duration: this.duration / this.options.speed,
|
||||
fltr: false,
|
||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||
})
|
||||
@ -270,7 +276,7 @@ class GroundText extends Base {
|
||||
image: canvas.toDataURL('image/png'),
|
||||
color: this.options.color,
|
||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||
duration: this.options.duration / this.options.speed,
|
||||
duration: this.duration / this.options.speed,
|
||||
fltr: false,
|
||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||
})
|
||||
@ -328,7 +334,7 @@ class GroundText extends Base {
|
||||
image: canvas.toDataURL('image/png'),
|
||||
color: this.options.color,
|
||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||
duration: this.options.duration / this.options.speed,
|
||||
duration: this.duration / this.options.speed,
|
||||
fltr: false,
|
||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||
}),
|
||||
@ -505,6 +511,10 @@ class GroundText extends Base {
|
||||
})
|
||||
})
|
||||
} else {
|
||||
if (this._positionEditingCallback) {
|
||||
this._positionEditingCallback()
|
||||
this._positionEditingCallback = null
|
||||
}
|
||||
if (this.event) {
|
||||
this.event.mouse_move(() => { })
|
||||
this.event.mouse_left(() => { })
|
||||
@ -520,6 +530,11 @@ class GroundText extends Base {
|
||||
return this._positionEditing
|
||||
}
|
||||
|
||||
openPositionEditing(cd) {
|
||||
this.positionEditing = true
|
||||
this._positionEditingCallback = cd
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞到
|
||||
*/
|
||||
|
@ -56,13 +56,9 @@ class StandText extends Base {
|
||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||
this.nodePoints = []
|
||||
this.entity
|
||||
this.options.instruct = options.instruct || ""
|
||||
this.options.operatingPoint = options.operatingPoint || ""
|
||||
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.attributeType = options.attributeType || 'richText'
|
||||
|
||||
delete this.options.name
|
||||
|
||||
this.extrudedHeight
|
||||
this._EventBinding = new EventBinding()
|
||||
this.Dialog = _Dialog
|
||||
@ -71,6 +67,9 @@ class StandText extends Base {
|
||||
StandText.create(this)
|
||||
}
|
||||
|
||||
get name() {
|
||||
return
|
||||
}
|
||||
get text() {
|
||||
return this.options.text
|
||||
}
|
||||
@ -297,14 +296,6 @@ class StandText extends Base {
|
||||
|
||||
// }
|
||||
|
||||
get attributeCamera() {
|
||||
return this.options.attribute.camera
|
||||
}
|
||||
|
||||
set attributeCamera(v) {
|
||||
this.options.attribute.camera = v
|
||||
}
|
||||
|
||||
//创建
|
||||
static async create(that) {
|
||||
|
||||
@ -397,15 +388,13 @@ class StandText extends Base {
|
||||
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
||||
},
|
||||
secondaryEditCallBack: () => {
|
||||
StandText.nodeEdit(this)
|
||||
this.nodeEdit()
|
||||
}
|
||||
})
|
||||
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' stand-text'
|
||||
let contentElm = document.createElement('div');
|
||||
contentElm.innerHTML = html(this)
|
||||
this._DialogObject.contentAppChild(contentElm)
|
||||
this.attributeType = this.options.attributeType
|
||||
this.attributeCamera = this.options.attribute.camera
|
||||
// setTimeout(() => {
|
||||
// this.attributeLink = this.options.attribute.link.content
|
||||
// this.cameraSelect()
|
||||
@ -538,23 +527,24 @@ class StandText extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
static nodeEdit(that, cb = () => { }) {
|
||||
nodeEdit(cb = () => { }) {
|
||||
if (YJ.Measure.GetMeasureStatus()) {
|
||||
cb('上一次测量未结束')
|
||||
} else {
|
||||
YJ.Measure.SetMeasureStatus(true)
|
||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
||||
that.event = new MouseEvent(that.sdk)
|
||||
that.nodePoints = []
|
||||
this._nodeEditCallback = cb
|
||||
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.nodePoints = []
|
||||
let selectPoint
|
||||
let originalPosition
|
||||
|
||||
let positions = that.options.positions
|
||||
let positions = this.options.positions
|
||||
let fromDegreesArray = []
|
||||
let minimumHeights = []
|
||||
let maximumHeights = []
|
||||
let width = that.computeDistance2(positions)
|
||||
let extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
let width = this.computeDistance2(positions)
|
||||
let extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
@ -565,55 +555,55 @@ class StandText extends Base {
|
||||
let leftEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
isAdd = true
|
||||
let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity])
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer)
|
||||
originalPosition = that.options.positions[selectPoint.index]
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity])
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
||||
originalPosition = this.options.positions[selectPoint.index]
|
||||
let entity = this.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, that.options.positions[selectPoint.index].alt),
|
||||
position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, this.options.positions[selectPoint.index].alt),
|
||||
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.splice(selectPoint.index, 0, entity)
|
||||
that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index])
|
||||
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index])
|
||||
|
||||
let positions = that.options.positions
|
||||
let positions = this.options.positions
|
||||
fromDegreesArray = []
|
||||
minimumHeights = []
|
||||
maximumHeights = []
|
||||
width = that.computeDistance2(positions)
|
||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
width = this.computeDistance2(positions)
|
||||
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.position.x,
|
||||
movement.position.y
|
||||
)
|
||||
}
|
||||
else {
|
||||
var pick = that.sdk.viewer.scene.pick(movement.position);
|
||||
var pick = this.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)
|
||||
that.entity.wall.positions = new Cesium.CallbackProperty(function () {
|
||||
this.nodePoints.splice(pick.id.index, 1)
|
||||
this.sdk.viewer.entities.remove(pick.id)
|
||||
this.tip.set_text('左键开始,右键结束,CTRL+右键撤销')
|
||||
originalPosition = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
this.entity.wall.positions = new Cesium.CallbackProperty(function () {
|
||||
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||
}, false)
|
||||
that.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () {
|
||||
this.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () {
|
||||
return maximumHeights
|
||||
}, false)
|
||||
that.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () {
|
||||
this.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () {
|
||||
return minimumHeights
|
||||
}, false)
|
||||
}
|
||||
@ -621,69 +611,69 @@ class StandText extends Base {
|
||||
}
|
||||
let rightEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = originalPosition
|
||||
this.options.positions[selectPoint.index] = originalPosition
|
||||
if(isAdd) {
|
||||
that.options.positions.splice(selectPoint.index, 1)
|
||||
this.options.positions.splice(selectPoint.index, 1)
|
||||
}
|
||||
cb(null, that.options.positions)
|
||||
cb(null, this.options.positions)
|
||||
}
|
||||
let positions = that.options.positions
|
||||
let positions = this.options.positions
|
||||
fromDegreesArray = []
|
||||
minimumHeights = []
|
||||
maximumHeights = []
|
||||
width = that.computeDistance2(positions)
|
||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
width = this.computeDistance2(positions)
|
||||
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||
}
|
||||
that.entity.wall.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||
this.entity.wall.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||
|
||||
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 = []
|
||||
this.nodePoints = []
|
||||
YJ.Measure.SetMeasureStatus(false)
|
||||
that.event.destroy()
|
||||
that.tip.destroy()
|
||||
this.event.destroy()
|
||||
this.tip.destroy()
|
||||
}
|
||||
|
||||
that.event.mouse_left(leftEvent)
|
||||
this.event.mouse_left(leftEvent)
|
||||
|
||||
that.event.mouse_right(rightEvent)
|
||||
this.event.mouse_right(rightEvent)
|
||||
|
||||
that.event.mouse_move((movement, cartesian) => {
|
||||
this.event.mouse_move((movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity])
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer)
|
||||
let positions = that.options.positions
|
||||
let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity])
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
||||
let positions = this.options.positions
|
||||
fromDegreesArray = []
|
||||
minimumHeights = []
|
||||
maximumHeights = []
|
||||
width = that.computeDistance2(positions)
|
||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
width = this.computeDistance2(positions)
|
||||
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||
}
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.endPosition.x,
|
||||
movement.endPosition.y
|
||||
)
|
||||
})
|
||||
|
||||
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||
this.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]
|
||||
this.options.positions.pop()
|
||||
this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1])
|
||||
this.nodePoints.pop()
|
||||
if (selectPoint.index === this.options.positions.length) {
|
||||
if (this.nodePoints[selectPoint.index - 1]) {
|
||||
selectPoint = this.nodePoints[selectPoint.index - 1]
|
||||
}
|
||||
else {
|
||||
selectPoint.index = 0
|
||||
@ -692,7 +682,7 @@ class StandText extends Base {
|
||||
}
|
||||
})
|
||||
|
||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||
let startTime = new Date()
|
||||
let pos = {
|
||||
position: {
|
||||
@ -700,7 +690,7 @@ class StandText extends Base {
|
||||
y: (movement.position1.y + movement.position2.y) / 2
|
||||
}
|
||||
}
|
||||
that.event.gesture_pinck_end(() => {
|
||||
this.event.gesture_pinck_end(() => {
|
||||
let endTime = new Date()
|
||||
if (endTime - startTime >= 500) {
|
||||
// 长按取消
|
||||
@ -712,20 +702,20 @@ class StandText extends Base {
|
||||
})
|
||||
})
|
||||
|
||||
for (let i = 0; i < that.options.positions.length; i++) {
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
let entity = this.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, that.options.positions[i].alt),
|
||||
position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat, this.options.positions[i].alt),
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ import { syncData, getSdk as get2DSdk } from '../../Global/MultiViewportMode'
|
||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../Global/global'
|
||||
|
||||
class Base extends Tools {
|
||||
#_showView
|
||||
#_isShowView
|
||||
constructor(sdk, options = {}) {
|
||||
super(sdk, options);
|
||||
if (!sdk || !sdk.viewer) {
|
||||
@ -32,8 +30,13 @@ class Base extends Tools {
|
||||
this.rightClickCallBack = null
|
||||
this.picking = true
|
||||
this.options.host = this.options.host || getHost()
|
||||
// this.#_showView = this.options.showView || 0
|
||||
this.options.customView = options.customView ||{
|
||||
relativePosition: undefined,
|
||||
orientation: undefined
|
||||
}
|
||||
// this._showView = this.options.showView || 0
|
||||
this.setDefaultValue()
|
||||
this._showView
|
||||
|
||||
// this.sdk.addIncetance(this.options.id, this)
|
||||
}
|
||||
@ -60,7 +63,7 @@ class Base extends Tools {
|
||||
// }
|
||||
|
||||
get showView() {
|
||||
return this.#_showView
|
||||
return this._showView
|
||||
}
|
||||
|
||||
set showView(v) {
|
||||
@ -68,28 +71,28 @@ class Base extends Tools {
|
||||
|
||||
let sdk2D = get2DSdk().sdkD
|
||||
if (!sdk2D) {
|
||||
this.#_showView = v
|
||||
this._showView = v
|
||||
if (this.entity) {
|
||||
this.entity._showView = v
|
||||
}
|
||||
return
|
||||
}
|
||||
if (this.sdk === sdk2D) {
|
||||
this.#_showView = 0
|
||||
this._showView = 0
|
||||
return
|
||||
}
|
||||
if (!this.#_showView && !this.show) {
|
||||
if (!this._showView && !this.show) {
|
||||
return
|
||||
}
|
||||
if (this.sdk === sdk2D) {
|
||||
this.#_showView = 0
|
||||
this._showView = 0
|
||||
return
|
||||
}
|
||||
if (v != 2 && v != 3) {
|
||||
this.#_showView = 0
|
||||
this._showView = 0
|
||||
}
|
||||
else {
|
||||
this.#_showView = v
|
||||
this._showView = v
|
||||
}
|
||||
|
||||
this.isShowView = true
|
||||
@ -98,7 +101,7 @@ class Base extends Tools {
|
||||
// return
|
||||
// }
|
||||
|
||||
if (!this.#_showView) {
|
||||
if (!this._showView) {
|
||||
this.show = true
|
||||
}
|
||||
else {
|
||||
@ -502,7 +505,10 @@ class Base extends Tools {
|
||||
|
||||
// 重置视角
|
||||
resetCustomView() {
|
||||
this.options.customView = undefined
|
||||
this.options.customView = {
|
||||
relativePosition: undefined,
|
||||
orientation: undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@ class EventBinding {
|
||||
}
|
||||
|
||||
on(that, elements) {
|
||||
return
|
||||
this.element = {}
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
if (!elements[i] || !elements[i].attributes) {
|
||||
|
@ -127,9 +127,9 @@ class Tools {
|
||||
var alt = cartographic.height < 0 ? 0 : cartographic.height
|
||||
// var alt = cartographic.height
|
||||
return {
|
||||
lng: lng,
|
||||
lat: lat,
|
||||
alt: alt,
|
||||
lng: Number(lng.toFixed(8)),
|
||||
lat: Number(lat.toFixed(8)),
|
||||
alt: Number(alt.toFixed(2)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,13 +141,14 @@ class Tools {
|
||||
* @param [fractionDigits=2] 保留小数点位数
|
||||
* @param [ground=true] 是否贴地
|
||||
* */
|
||||
async computeDistance(positions = [], fractionDigits = 2, type = '空间长度') {
|
||||
async computeDistance(positions = [], fractionDigits = 2, type = 0) {
|
||||
if (positions.length < 2) {
|
||||
return 0
|
||||
} else {
|
||||
let length = 0
|
||||
switch (type) {
|
||||
case '空间长度':
|
||||
case '0':
|
||||
case 0:
|
||||
for (let i = 0; i < positions.length - 1; i++) {
|
||||
const position1 = Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, positions[i].alt);
|
||||
const position2 = Cesium.Cartesian3.fromDegrees(positions[i + 1].lng, positions[i + 1].lat, positions[i + 1].alt);
|
||||
@ -155,7 +156,8 @@ class Tools {
|
||||
length = length + distance
|
||||
}
|
||||
break
|
||||
case '投影长度':
|
||||
case '1':
|
||||
case 1:
|
||||
for (let i = 0; i < positions.length - 1; i++) {
|
||||
const position1 = Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, 0);
|
||||
const position2 = Cesium.Cartesian3.fromDegrees(positions[i + 1].lng, positions[i + 1].lat, 0);
|
||||
@ -163,7 +165,8 @@ class Tools {
|
||||
length = length + distance
|
||||
}
|
||||
break
|
||||
case '地表长度':
|
||||
case '2':
|
||||
case 2:
|
||||
let meters
|
||||
let lineString2 = []
|
||||
positions.forEach((item) => {
|
||||
@ -1243,14 +1246,28 @@ class Tools {
|
||||
* */
|
||||
deepCopyObj(obj) {
|
||||
let newobj = null;
|
||||
//判断是否需要继续进行递归
|
||||
if (typeof (obj) == 'object' && obj !== null) {
|
||||
newobj = obj instanceof Array ? [] : {}; //进行下一层递归克隆
|
||||
// 处理数组 - 使用原生Array构造函数创建新数组
|
||||
if (Array.isArray(obj)) {
|
||||
newobj = [];
|
||||
// 只拷贝数组元素,不拷贝可能存在的扩展方法
|
||||
for (let i = 0; i < obj.length; i++) {
|
||||
newobj[i] = this.deepCopyObj(obj[i]);
|
||||
}
|
||||
return newobj;
|
||||
}
|
||||
|
||||
// 处理对象
|
||||
else if (obj && typeof obj === 'object') {
|
||||
newobj = {};
|
||||
for (let i in obj) {
|
||||
if (i != 'earth' && i != 'Dialog')
|
||||
newobj[i] = this.deepCopyObj(obj[i])
|
||||
} //如果不是对象直接赋值
|
||||
} else newobj = obj;
|
||||
// 排除指定属性和方法属性
|
||||
if (i !== 'earth' && i !== 'Dialog' && typeof obj[i] !== 'function') {
|
||||
newobj[i] = this.deepCopyObj(obj[i]);
|
||||
}
|
||||
}
|
||||
return newobj;
|
||||
}
|
||||
else newobj = obj;
|
||||
return newobj;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -65,7 +65,7 @@
|
||||
position: absolute;
|
||||
color: var(--color-sdk-auxiliary-public);
|
||||
font-size: 14px;
|
||||
z-index: 999999;
|
||||
z-index: 99;
|
||||
background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6);
|
||||
border: 1.5px solid;
|
||||
border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1;
|
||||
@ -76,8 +76,6 @@
|
||||
}
|
||||
|
||||
.YJ-custom-base-dialog * {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@ -171,7 +169,7 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.YJ-custom-base-dialog button:not(button[disabled="disabled"]):hover {
|
||||
.YJ-custom-base-dialog button:not(button[disabled]):hover {
|
||||
border-color: rgba(var(--color-sdk-base-rgb), 1) !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
@ -3888,3 +3886,81 @@
|
||||
/* 移回顶部外 */
|
||||
}
|
||||
}
|
||||
|
||||
.yj-custom-icon {
|
||||
display: inline-block;
|
||||
width: 22px;
|
||||
height: 10px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.yj-custom-icon.line {
|
||||
border: 1px solid rgba(255, 255, 255, 1);
|
||||
height: 0px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.yj-custom-icon.dash-line {
|
||||
border: 1px dashed rgba(255, 255, 255, 1);
|
||||
height: 0px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.yj-custom-icon.light-line {
|
||||
border: 1px solid rgba(255, 255, 255, 1);
|
||||
height: 0px;
|
||||
margin-top: 4px;
|
||||
box-shadow: 0 0 3px #fff
|
||||
}
|
||||
|
||||
.yj-custom-icon.tail-line {
|
||||
background: url(../../img/arrow/tail.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.mult-tail-line {
|
||||
background: url(../../img/arrow/tail.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.flow-dash-line1 {
|
||||
border: 1px dashed rgba(255, 255, 255, 1);
|
||||
height: 0px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.yj-custom-icon.flow-dash-line2 {
|
||||
border: 1px dashed rgba(255, 255, 255, 1);
|
||||
height: 0px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.yj-custom-icon.pic-line1 {
|
||||
background: url(../../img/arrow/1.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.pic-line2 {
|
||||
background: url(../../img/arrow/2.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.pic-line3 {
|
||||
background: url(../../img/arrow/3.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.pic-line4 {
|
||||
background: url(../../img/arrow/4.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.pic-line5 {
|
||||
background: url(../../img/arrow/5.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
.yj-custom-icon.pic-line6 {
|
||||
background: url(../../img/arrow/6.png) 100% 100% no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
Reference in New Issue
Block a user