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.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param options.areaUnit='平方米' {string} 面积单位
|
|
||||||
* @param options.line {object} 边框
|
* @param options.line {object} 边框
|
||||||
* @param options.line.width=2 {string} 边框宽
|
* @param options.line.width=2 {string} 边框宽
|
||||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {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 = options.line || {}
|
||||||
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
|
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.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
|
||||||
this.entity
|
this.entity
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
this.operate = {}
|
this.operate = {}
|
||||||
@ -105,13 +103,11 @@ class AssembleObject extends Base {
|
|||||||
this.options.attribute = options.attribute || {}
|
this.options.attribute = options.attribute || {}
|
||||||
this.options.attribute.link = this.options.attribute.link || {}
|
this.options.attribute.link = this.options.attribute.link || {}
|
||||||
this.options.attribute.link.content = this.options.attribute.link.content || []
|
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 || []
|
delete this.options.attribute.camera
|
||||||
this.options.attribute.vr = this.options.attribute.vr || {}
|
delete this.options.attribute.vr
|
||||||
this.options.attribute.vr.content = this.options.attribute.vr.content || []
|
delete this.options.attribute.goods
|
||||||
this.options.attribute.goods = this.options.attribute.goods || {}
|
|
||||||
this.options.attribute.goods.content = this.options.attribute.goods.content || []
|
|
||||||
this.options.attributeType = options.attributeType || 'richText'
|
|
||||||
this.nodePoints = []
|
this.nodePoints = []
|
||||||
if (!this.options.positions || this.options.positions.length < 3) {
|
if (!this.options.positions || this.options.positions.length < 3) {
|
||||||
this._error = '集结地最少需要三个坐标!'
|
this._error = '集结地最少需要三个坐标!'
|
||||||
@ -189,7 +185,7 @@ class AssembleObject extends Base {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let heightModeName = ''
|
let heightModeName = ''
|
||||||
AssembleObject.closeNodeEdit(this)
|
this.closeNodeEdit()
|
||||||
let ground = false
|
let ground = false
|
||||||
let disabled = false
|
let disabled = false
|
||||||
this.renewPositions()
|
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() {
|
get labelShow() {
|
||||||
return this.options.label.show
|
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) {
|
static create(that) {
|
||||||
let positions = that.options.positions
|
let positions = that.options.positions
|
||||||
let fromDegreesArray = []
|
let fromDegreesArray = []
|
||||||
@ -919,9 +563,10 @@ class AssembleObject extends Base {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!that.options.label.position) {
|
// 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.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||||
}
|
|
||||||
|
|
||||||
let fromDegreesArray2 = []
|
let fromDegreesArray2 = []
|
||||||
for (let i = 0; i < points[0].length; i++) {
|
for (let i = 0; i < points[0].length; i++) {
|
||||||
@ -939,7 +584,7 @@ class AssembleObject extends Base {
|
|||||||
color: that.options.color
|
color: that.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
that.options.label.ground = ground
|
// that.options.label.ground = ground
|
||||||
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
||||||
|
|
||||||
that.entity = that.sdk.viewer.entities.add({
|
that.entity = that.sdk.viewer.entities.add({
|
||||||
@ -967,23 +612,8 @@ class AssembleObject extends Base {
|
|||||||
for (let i = 0; i < positionsA.length; i++) {
|
for (let i = 0; i < positionsA.length; i++) {
|
||||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||||
}
|
}
|
||||||
that.options.areaByMeter = that.computeArea(pos84);
|
that.areaByMeter = that.computeArea(pos84);
|
||||||
switch (that.options['area-unit']) {
|
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||||
case '平方米':
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
break;
|
|
||||||
case '平方千米':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
||||||
break;
|
|
||||||
case '亩':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
||||||
break;
|
|
||||||
case '公顷':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
}
|
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
if (that.options.show) {
|
if (that.options.show) {
|
||||||
setSplitDirection(0, that.options.id)
|
setSplitDirection(0, that.options.id)
|
||||||
@ -1007,12 +637,13 @@ class AssembleObject extends Base {
|
|||||||
scaleByDistance: that.options.label.scaleByDistance,
|
scaleByDistance: that.options.label.scaleByDistance,
|
||||||
near: that.options.label.near,
|
near: that.options.label.near,
|
||||||
far: that.options.label.far,
|
far: that.options.label.far,
|
||||||
ground: that.options.label.ground,
|
// ground: that.options.label.ground,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑框
|
// 编辑框
|
||||||
async edit(state) {
|
async edit(state) {
|
||||||
|
return
|
||||||
if (this._error) {
|
if (this._error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1446,7 +1077,6 @@ class AssembleObject extends Base {
|
|||||||
if (unitDataLegpObject) {
|
if (unitDataLegpObject) {
|
||||||
unitDataLegpObject.legp_search(unitData)
|
unitDataLegpObject.legp_search(unitData)
|
||||||
let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-select-unit')[0].getElementsByTagName('input')[0]
|
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++) {
|
for (let i = 0; i < unitData.length; i++) {
|
||||||
if (unitData[i].value === unitDataLegpElm.value) {
|
if (unitData[i].value === unitDataLegpElm.value) {
|
||||||
unitDataLegpObject.legp_searchActive(unitData[i].value)
|
unitDataLegpObject.legp_searchActive(unitData[i].value)
|
||||||
@ -1511,8 +1141,6 @@ class AssembleObject extends Base {
|
|||||||
this.color = this.originalOptions.color
|
this.color = this.originalOptions.color
|
||||||
this.lineColor = this.originalOptions.line.color
|
this.lineColor = this.originalOptions.line.color
|
||||||
this.lineWidth = this.originalOptions.line.width
|
this.lineWidth = this.originalOptions.line.width
|
||||||
this.area = this.originalOptions.area
|
|
||||||
this.areaUnit = this.originalOptions['area-unit']
|
|
||||||
this.labelShow = this.originalOptions.label.show
|
this.labelShow = this.originalOptions.label.show
|
||||||
this.labelColor = this.originalOptions.label.color
|
this.labelColor = this.originalOptions.label.color
|
||||||
this.labelFontSize = this.originalOptions.label.fontSize
|
this.labelFontSize = this.originalOptions.label.fontSize
|
||||||
@ -1525,12 +1153,6 @@ class AssembleObject extends Base {
|
|||||||
this.labelLineColor = this.originalOptions.label.lineColor
|
this.labelLineColor = this.originalOptions.label.lineColor
|
||||||
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
||||||
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
|
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++) {
|
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)
|
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.positions = newpositions
|
||||||
this.previous = null
|
this.previous = null
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
|
|
||||||
|
if(this._positionEditingCallback) {
|
||||||
|
this._positionEditingCallback()
|
||||||
|
this._positionEditingCallback = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.event.mouse_right((movement, cartesian) => {
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
@ -1919,131 +1501,47 @@ class AssembleObject extends Base {
|
|||||||
get positionEditing() {
|
get positionEditing() {
|
||||||
return this.operate.positionEditing
|
return this.operate.positionEditing
|
||||||
}
|
}
|
||||||
|
openPositionEditing(cd) {
|
||||||
static EventBinding(that, elements) {
|
this.positionEditing = true
|
||||||
for (let i = 0; i < elements.length; i++) {
|
this._positionEditingCallback = cd
|
||||||
let Event = []
|
|
||||||
let isEvent = false
|
|
||||||
let removeName = []
|
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
for (let m of elements[i].attributes) {
|
get areaChangeCallBack() {
|
||||||
switch (m.name) {
|
return this._areaChangeCallBack
|
||||||
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) {
|
set areaChangeCallBack (cd) {
|
||||||
let ventType = 'input'
|
this._areaChangeCallBack = cd
|
||||||
if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') {
|
|
||||||
ventType = 'change'
|
|
||||||
}
|
|
||||||
elements[i].addEventListener(ventType, (e) => {
|
|
||||||
for (let t = 0; t < Event.length; t++) {
|
|
||||||
Event[t](e)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static nodeEdit(that, cb = () => { }) {
|
nodeEdit(cb = () => { }) {
|
||||||
that.positionEditing = false
|
this.positionEditing = false
|
||||||
if (YJ.Measure.GetMeasureStatus()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
cb('上一次测量未结束')
|
cb('上一次测量未结束')
|
||||||
} else {
|
} else {
|
||||||
YJ.Measure.SetMeasureStatus(true)
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
let _this = this
|
||||||
that.event = new MouseEvent(that.sdk)
|
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||||
that.nodePoints = []
|
this.event = new MouseEvent(this.sdk)
|
||||||
|
this.nodePoints = []
|
||||||
let selectPoint
|
let selectPoint
|
||||||
let originalPosition
|
let originalPosition
|
||||||
let fromDegreesArray = []
|
let fromDegreesArray = []
|
||||||
for (let i = 0; i < that.options.positions.length; i++) {
|
for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
fromDegreesArray.push(that.options.positions[i].lng, that.options.positions[i].lat)
|
fromDegreesArray.push(this.options.positions[i].lng, this.options.positions[i].lat)
|
||||||
}
|
}
|
||||||
|
|
||||||
let moveEvent = (movement, cartesian) => {
|
let moveEvent = (movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||||
}
|
}
|
||||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
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,
|
cartesian,
|
||||||
movement.position ? movement.position.x : movement.endPosition.x,
|
movement.position ? movement.position.x : movement.endPosition.x,
|
||||||
movement.position ? movement.position.y : movement.endPosition.y
|
movement.position ? movement.position.y : movement.endPosition.y
|
||||||
@ -2052,25 +1550,25 @@ class AssembleObject extends Base {
|
|||||||
|
|
||||||
let leftEvent = (movement, cartesian) => {
|
let leftEvent = (movement, cartesian) => {
|
||||||
moveEvent(movement, cartesian)
|
moveEvent(movement, cartesian)
|
||||||
let position84 = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
let position84 = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
let index = 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',
|
name: 'node-secondary-edit-point',
|
||||||
index: index,
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||||
selectPoint = null
|
selectPoint = null
|
||||||
|
|
||||||
that.tip.set_text('请选择一个顶点,右键取消')
|
this.tip.set_text('请选择一个顶点,右键取消')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let position = movement.position
|
let position = movement.position
|
||||||
@ -2080,49 +1578,50 @@ class AssembleObject extends Base {
|
|||||||
y: (movement.position1.y + movement.position2.y) / 2
|
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') {
|
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||||
selectPoint = pick.id
|
selectPoint = pick.id
|
||||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||||
that.nodePoints.splice(pick.id.index, 1)
|
this.nodePoints.splice(pick.id.index, 1)
|
||||||
that.sdk.viewer.entities.remove(pick.id)
|
this.sdk.viewer.entities.remove(pick.id)
|
||||||
that.tip.set_text('左键确认,右键取消')
|
this.tip.set_text('左键确认,右键取消')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.renewPositions()
|
this.renewPositions()
|
||||||
|
cb('', [...this.options.positions])
|
||||||
}
|
}
|
||||||
let rightEvent = () => {
|
let rightEvent = () => {
|
||||||
that.event.mouse_move(() => { })
|
this.event.mouse_move(() => { })
|
||||||
that.event.mouse_left(() => { })
|
this.event.mouse_left(() => { })
|
||||||
that.event.mouse_right(() => { })
|
this.event.mouse_right(() => { })
|
||||||
that.event.gesture_pinck_start(() => { })
|
this.event.gesture_pinck_start(() => { })
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
if (!originalPosition) {
|
if (!originalPosition) {
|
||||||
that.options.positions.pop()
|
this.options.positions.pop()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
that.options.positions[selectPoint.index] = originalPosition
|
this.options.positions[selectPoint.index] = originalPosition
|
||||||
}
|
}
|
||||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||||
}
|
}
|
||||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.heightMode = that.heightMode
|
this.heightMode = this.heightMode
|
||||||
that.previous = null
|
this.previous = null
|
||||||
}
|
}
|
||||||
|
|
||||||
that.entity.polyline.clampToGround = true
|
this.entity.polyline.clampToGround = true
|
||||||
that.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
this.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
||||||
that.entity.polygon.perPositionHeight = false
|
this.entity.polygon.perPositionHeight = false
|
||||||
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||||
let arr = that.computeAssemble(that.options.positions)
|
let arr = _this.computeAssemble(_this.options.positions)
|
||||||
return new Cesium.PolygonHierarchy(arr)
|
return new Cesium.PolygonHierarchy(arr)
|
||||||
}, false)
|
}, false)
|
||||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||||
let arr = that.computeAssemble(that.options.positions)
|
let arr = _this.computeAssemble(_this.options.positions)
|
||||||
if (arr.length >= 3) {
|
if (arr.length >= 3) {
|
||||||
return [...arr, arr[0], arr[1]]
|
return [...arr, arr[0], arr[1]]
|
||||||
}
|
}
|
||||||
@ -2134,23 +1633,23 @@ class AssembleObject extends Base {
|
|||||||
|
|
||||||
let points = [[]]
|
let points = [[]]
|
||||||
let pos84 = []
|
let pos84 = []
|
||||||
for (let i = 0; i < that.positionsH.length; i++) {
|
for (let i = 0; i < this.positionsH.length; i++) {
|
||||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||||
pos84.push(position)
|
pos84.push(position)
|
||||||
points[0].push([position.lng, position.lat])
|
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])
|
points[0].push([position.lng, position.lat])
|
||||||
let polygon = turf.polygon(points)
|
let polygon = turf.polygon(points)
|
||||||
let centroid = turf.pointOnFeature(polygon)
|
let centroid = turf.pointOnFeature(polygon)
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||||
that
|
this
|
||||||
.getClampToHeight({
|
.getClampToHeight({
|
||||||
lng: centroid.geometry.coordinates[0],
|
lng: centroid.geometry.coordinates[0],
|
||||||
lat: centroid.geometry.coordinates[1]
|
lat: centroid.geometry.coordinates[1]
|
||||||
}, objectsToExclude)
|
}, objectsToExclude)
|
||||||
.then(height => {
|
.then(height => {
|
||||||
that.label.position = [
|
this.label.position = [
|
||||||
centroid.geometry.coordinates[0],
|
centroid.geometry.coordinates[0],
|
||||||
centroid.geometry.coordinates[1],
|
centroid.geometry.coordinates[1],
|
||||||
height
|
height
|
||||||
@ -2159,15 +1658,15 @@ class AssembleObject extends Base {
|
|||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
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()
|
let startTime = new Date()
|
||||||
that.event.gesture_pinck_end(() => {
|
this.event.gesture_pinck_end(() => {
|
||||||
let endTime = new Date()
|
let endTime = new Date()
|
||||||
let pos = {
|
let pos = {
|
||||||
position: {
|
position: {
|
||||||
@ -2187,31 +1686,31 @@ class AssembleObject extends Base {
|
|||||||
createNodePoints()
|
createNodePoints()
|
||||||
}, 200);
|
}, 200);
|
||||||
async function createNodePoints() {
|
async function createNodePoints() {
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||||
for (let i = 0; i < that.options.positions.length; i++) {
|
for (let i = 0; i < _this.options.positions.length; i++) {
|
||||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = _this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
name: 'node-secondary-edit-point',
|
||||||
index: i,
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: _this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
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++) {
|
// for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
// let entity = that.sdk.viewer.entities.add({
|
// let entity = this.sdk.viewer.entities.add({
|
||||||
// name: 'node-secondary-edit-point',
|
// name: 'node-secondary-edit-point',
|
||||||
// index: i,
|
// 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: {
|
// billboard: {
|
||||||
// image: that.getSourceRootPath() + '/img/point.png',
|
// image: this.getSourceRootPath() + '/img/point.png',
|
||||||
// width: 15,
|
// width: 15,
|
||||||
// height: 15,
|
// height: 15,
|
||||||
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
@ -2222,17 +1721,17 @@ class AssembleObject extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static closeNodeEdit(that) {
|
closeNodeEdit() {
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event && that.event.destroy()
|
this.event && this.event.destroy()
|
||||||
that.tip && that.tip.destroy()
|
this.tip && this.tip.destroy()
|
||||||
that.tip = null
|
this.tip = null
|
||||||
|
|
||||||
for (let i = 0; i < that.nodePoints.length; i++) {
|
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||||
}
|
}
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
that.picking = true
|
this.picking = true
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(v) {
|
setPosition(v) {
|
||||||
@ -2323,7 +1822,7 @@ class AssembleObject extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新坐标
|
// 更新坐标
|
||||||
renewPositions(position84) {
|
renewPositions(position84, cd) {
|
||||||
if (this._error || !this.sdk.viewer) {
|
if (this._error || !this.sdk.viewer) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2410,8 +1909,8 @@ class AssembleObject extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 计算投影面积
|
// 计算投影面积
|
||||||
this.options.areaByMeter = this.computeArea(pos84)
|
this.areaByMeter = this.computeArea(pos84)
|
||||||
this.areaUnit = this.areaUnit
|
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||||
return fromDegreesArray
|
return fromDegreesArray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@ class AttackArrowObject extends Base {
|
|||||||
this.options.line = options.line || {}
|
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.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.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
|
||||||
this.entity
|
this.entity
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
this.operate = {}
|
this.operate = {}
|
||||||
@ -112,13 +111,11 @@ class AttackArrowObject extends Base {
|
|||||||
this.options.attribute = options.attribute || {}
|
this.options.attribute = options.attribute || {}
|
||||||
this.options.attribute.link = this.options.attribute.link || {}
|
this.options.attribute.link = this.options.attribute.link || {}
|
||||||
this.options.attribute.link.content = this.options.attribute.link.content || []
|
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 || []
|
delete this.options.attribute.camera
|
||||||
this.options.attribute.vr = this.options.attribute.vr || {}
|
delete this.options.attribute.vr
|
||||||
this.options.attribute.vr.content = this.options.attribute.vr.content || []
|
delete this.options.attribute.goods
|
||||||
this.options.attribute.goods = this.options.attribute.goods || {}
|
|
||||||
this.options.attribute.goods.content = this.options.attribute.goods.content || []
|
|
||||||
this.options.attributeType = options.attributeType || 'richText'
|
|
||||||
|
|
||||||
if (!this.options.positions || this.options.positions.length < 3) {
|
if (!this.options.positions || this.options.positions.length < 3) {
|
||||||
this._error = '箭头面最少需要三个坐标!'
|
this._error = '箭头面最少需要三个坐标!'
|
||||||
@ -196,7 +193,7 @@ class AttackArrowObject extends Base {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let heightModeName = ''
|
let heightModeName = ''
|
||||||
AttackArrowObject.closeNodeEdit(this)
|
this.closeNodeEdit()
|
||||||
let ground = false
|
let ground = false
|
||||||
let disabled = false
|
let disabled = false
|
||||||
this.renewPositions()
|
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() {
|
get labelShow() {
|
||||||
return this.options.label.show
|
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) {
|
static create(that) {
|
||||||
let positions = that.options.positions
|
let positions = that.options.positions
|
||||||
let fromDegreesArray = []
|
let fromDegreesArray = []
|
||||||
@ -928,10 +573,11 @@ class AttackArrowObject extends Base {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!that.options.label.position) {
|
// 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.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||||
}
|
// that.options.label.ground = ground
|
||||||
that.options.label.ground = ground
|
|
||||||
|
|
||||||
let fromDegreesArray2 = []
|
let fromDegreesArray2 = []
|
||||||
for (let i = 0; i < points[0].length; i++) {
|
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++) {
|
for (let i = 0; i < positionsA.length; i++) {
|
||||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||||
}
|
}
|
||||||
that.options.areaByMeter = that.computeArea(pos84);
|
that.areaByMeter = that.computeArea(pos84);
|
||||||
switch (that.options['area-unit']) {
|
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||||
case '平方米':
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
break;
|
|
||||||
case '平方千米':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
||||||
break;
|
|
||||||
case '亩':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
||||||
break;
|
|
||||||
case '公顷':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
}
|
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
if (that.options.show) {
|
if (that.options.show) {
|
||||||
|
|
||||||
@ -1020,12 +651,13 @@ class AttackArrowObject extends Base {
|
|||||||
scaleByDistance: that.options.label.scaleByDistance,
|
scaleByDistance: that.options.label.scaleByDistance,
|
||||||
near: that.options.label.near,
|
near: that.options.label.near,
|
||||||
far: that.options.label.far,
|
far: that.options.label.far,
|
||||||
ground: that.options.label.ground,
|
// ground: that.options.label.ground,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑框
|
// 编辑框
|
||||||
async edit(state) {
|
async edit(state) {
|
||||||
|
return
|
||||||
if (this._error) {
|
if (this._error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1527,8 +1159,6 @@ class AttackArrowObject extends Base {
|
|||||||
this.color = this.originalOptions.color
|
this.color = this.originalOptions.color
|
||||||
this.lineColor = this.originalOptions.line.color
|
this.lineColor = this.originalOptions.line.color
|
||||||
this.lineWidth = this.originalOptions.line.width
|
this.lineWidth = this.originalOptions.line.width
|
||||||
this.area = this.originalOptions.area
|
|
||||||
this.areaUnit = this.originalOptions['area-unit']
|
|
||||||
this.labelShow = this.originalOptions.label.show
|
this.labelShow = this.originalOptions.label.show
|
||||||
this.labelColor = this.originalOptions.label.color
|
this.labelColor = this.originalOptions.label.color
|
||||||
this.labelFontSize = this.originalOptions.label.fontSize
|
this.labelFontSize = this.originalOptions.label.fontSize
|
||||||
@ -1541,12 +1171,6 @@ class AttackArrowObject extends Base {
|
|||||||
this.labelLineColor = this.originalOptions.label.lineColor
|
this.labelLineColor = this.originalOptions.label.lineColor
|
||||||
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
||||||
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
|
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++) {
|
for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
if (this._elms.lng && this._elms.lng[i]) {
|
if (this._elms.lng && this._elms.lng[i]) {
|
||||||
@ -1597,51 +1221,6 @@ class AttackArrowObject extends Base {
|
|||||||
await syncData(this.sdk, this.options.id)
|
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 打开平移功能
|
/**@desc 打开平移功能
|
||||||
*
|
*
|
||||||
@ -1844,6 +1413,11 @@ class AttackArrowObject extends Base {
|
|||||||
positions: [...this.positions]
|
positions: [...this.positions]
|
||||||
}
|
}
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
|
|
||||||
|
if(this._positionEditingCallback) {
|
||||||
|
this._positionEditingCallback()
|
||||||
|
this._positionEditingCallback = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.event.mouse_right((movement, cartesian) => {
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
@ -1946,6 +1520,18 @@ class AttackArrowObject extends Base {
|
|||||||
return this.operate.positionEditing
|
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) {
|
static EventBinding(that, elements) {
|
||||||
for (let i = 0; i < elements.length; i++) {
|
for (let i = 0; i < elements.length; i++) {
|
||||||
let Event = []
|
let Event = []
|
||||||
@ -2045,28 +1631,29 @@ class AttackArrowObject extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static nodeEdit(that, cb = () => { }) {
|
nodeEdit(cb = () => { }) {
|
||||||
that.positionEditing = false
|
this.positionEditing = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (YJ.Measure.GetMeasureStatus()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
cb('上一次测量未结束')
|
cb('上一次测量未结束')
|
||||||
} else {
|
} else {
|
||||||
that.removeAnimate()
|
this.removeAnimate()
|
||||||
YJ.Measure.SetMeasureStatus(true)
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
that.event && that.event.destroy()
|
let _this = this
|
||||||
that.tip && that.tip.destroy()
|
this.event && this.event.destroy()
|
||||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
this.tip && this.tip.destroy()
|
||||||
that.event = new MouseEvent(that.sdk)
|
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||||
that.nodePoints = []
|
this.event = new MouseEvent(this.sdk)
|
||||||
|
this.nodePoints = []
|
||||||
let selectPoint
|
let selectPoint
|
||||||
let originalPosition
|
let originalPosition
|
||||||
|
|
||||||
let moveEvent = (movement, cartesian) => {
|
let moveEvent = (movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
that.renewPositions()
|
this.renewPositions()
|
||||||
}
|
}
|
||||||
that.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.position ? movement.position.x : movement.endPosition.x,
|
movement.position ? movement.position.x : movement.endPosition.x,
|
||||||
movement.position ? movement.position.y : movement.endPosition.y
|
movement.position ? movement.position.y : movement.endPosition.y
|
||||||
@ -2075,17 +1662,17 @@ class AttackArrowObject extends Base {
|
|||||||
let leftEvent = (movement, cartesian) => {
|
let leftEvent = (movement, cartesian) => {
|
||||||
moveEvent(movement, cartesian)
|
moveEvent(movement, cartesian)
|
||||||
if (selectPoint) {
|
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
|
let index = selectPoint.index
|
||||||
if (selectPoint.index === that.options.positions.length - 1) {
|
if (selectPoint.index === this.options.positions.length - 1) {
|
||||||
index = index + 1
|
index = index + 1
|
||||||
}
|
}
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
name: 'node-secondary-edit-point',
|
||||||
index: index,
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
@ -2094,86 +1681,87 @@ class AttackArrowObject extends Base {
|
|||||||
})
|
})
|
||||||
selectPoint = entity
|
selectPoint = entity
|
||||||
|
|
||||||
originalPosition = that.options.positions[selectPoint.index]
|
originalPosition = this.options.positions[selectPoint.index]
|
||||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||||
|
|
||||||
if (index < that.options.positions.length) {
|
if (index < this.options.positions.length) {
|
||||||
selectPoint = null
|
selectPoint = null
|
||||||
that.tip.set_text('请选择一个顶点,右键取消')
|
this.tip.set_text('请选择一个顶点,右键取消')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index])
|
this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index])
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
}
|
}
|
||||||
that.renewPositions()
|
this.renewPositions()
|
||||||
|
cb('', [...this.options.positions])
|
||||||
}
|
}
|
||||||
else {
|
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') {
|
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||||
selectPoint = pick.id
|
selectPoint = pick.id
|
||||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||||
that.nodePoints.splice(pick.id.index, 1)
|
this.nodePoints.splice(pick.id.index, 1)
|
||||||
that.sdk.viewer.entities.remove(pick.id)
|
this.sdk.viewer.entities.remove(pick.id)
|
||||||
that.tip.set_text('左键确认,右键结束,CTRL+右键撤销')
|
this.tip.set_text('左键确认,右键结束,CTRL+右键撤销')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let rightEvent = (movement, cartesian) => {
|
let rightEvent = (movement, cartesian) => {
|
||||||
that.event.mouse_move(() => { })
|
this.event.mouse_move(() => { })
|
||||||
that.event.mouse_left(() => { })
|
this.event.mouse_left(() => { })
|
||||||
that.event.mouse_right(() => { })
|
this.event.mouse_right(() => { })
|
||||||
that.event.gesture_pinck_start(() => { })
|
this.event.gesture_pinck_start(() => { })
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
if (!originalPosition) {
|
if (!originalPosition) {
|
||||||
that.options.positions.pop()
|
this.options.positions.pop()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
that.options.positions[selectPoint.index] = originalPosition
|
this.options.positions[selectPoint.index] = originalPosition
|
||||||
if (that.options.positions.length > 3 && selectPoint.index === that.options.positions.length - 1) {
|
if (this.options.positions.length > 3 && selectPoint.index === this.options.positions.length - 1) {
|
||||||
that.options.positions.splice(selectPoint.index + 1, 1)
|
this.options.positions.splice(selectPoint.index + 1, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||||
}
|
}
|
||||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.heightMode = that.heightMode
|
this.heightMode = this.heightMode
|
||||||
that.previous = null
|
this.previous = null
|
||||||
}
|
}
|
||||||
|
|
||||||
that.entity.polyline.clampToGround = true
|
this.entity.polyline.clampToGround = true
|
||||||
that.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
this.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
||||||
that.entity.polygon.perPositionHeight = false
|
this.entity.polygon.perPositionHeight = false
|
||||||
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||||
return new Cesium.PolygonHierarchy(that.positionsH)
|
return new Cesium.PolygonHierarchy(_this.positionsH)
|
||||||
}, false)
|
}, false)
|
||||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||||
return [...that.positionsH, that.positionsH[0], that.positionsH[1]]
|
return [..._this.positionsH, _this.positionsH[0], _this.positionsH[1]]
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
|
|
||||||
let points = [[]]
|
let points = [[]]
|
||||||
let pos84 = []
|
let pos84 = []
|
||||||
for (let i = 0; i < that.positionsH.length; i++) {
|
for (let i = 0; i < this.positionsH.length; i++) {
|
||||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||||
pos84.push(position)
|
pos84.push(position)
|
||||||
points[0].push([position.lng, position.lat])
|
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])
|
points[0].push([position.lng, position.lat])
|
||||||
let polygon = turf.polygon(points)
|
let polygon = turf.polygon(points)
|
||||||
let centroid = turf.pointOnFeature(polygon)
|
let centroid = turf.pointOnFeature(polygon)
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||||
that
|
this
|
||||||
.getClampToHeight({
|
.getClampToHeight({
|
||||||
lng: centroid.geometry.coordinates[0],
|
lng: centroid.geometry.coordinates[0],
|
||||||
lat: centroid.geometry.coordinates[1]
|
lat: centroid.geometry.coordinates[1]
|
||||||
}, objectsToExclude)
|
}, objectsToExclude)
|
||||||
.then(height => {
|
.then(height => {
|
||||||
that.label.position = [
|
this.label.position = [
|
||||||
centroid.geometry.coordinates[0],
|
centroid.geometry.coordinates[0],
|
||||||
centroid.geometry.coordinates[1],
|
centroid.geometry.coordinates[1],
|
||||||
height
|
height
|
||||||
@ -2181,36 +1769,36 @@ class AttackArrowObject extends Base {
|
|||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
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) {
|
if (selectPoint) {
|
||||||
that.options.positions.pop()
|
this.options.positions.pop()
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1])
|
this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1])
|
||||||
that.nodePoints.pop()
|
this.nodePoints.pop()
|
||||||
if (!selectPoint.index) {
|
if (!selectPoint.index) {
|
||||||
// selectPoint = null
|
// selectPoint = null
|
||||||
}
|
}
|
||||||
else if (selectPoint.index === that.options.positions.length) {
|
else if (selectPoint.index === this.options.positions.length) {
|
||||||
if (that.nodePoints[selectPoint.index - 1]) {
|
if (this.nodePoints[selectPoint.index - 1]) {
|
||||||
selectPoint = that.nodePoints[selectPoint.index - 1]
|
selectPoint = this.nodePoints[selectPoint.index - 1]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selectPoint.index = selectPoint.index - 1
|
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()
|
let startTime = new Date()
|
||||||
that.event.gesture_pinck_end(() => {
|
this.event.gesture_pinck_end(() => {
|
||||||
let endTime = new Date()
|
let endTime = new Date()
|
||||||
let pos = {
|
let pos = {
|
||||||
position: {
|
position: {
|
||||||
@ -2230,31 +1818,31 @@ class AttackArrowObject extends Base {
|
|||||||
createNodePoints()
|
createNodePoints()
|
||||||
}, 200);
|
}, 200);
|
||||||
async function createNodePoints() {
|
async function createNodePoints() {
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||||
for (let i = 0; i < that.options.positions.length; i++) {
|
for (let i = 0; i < _this.options.positions.length; i++) {
|
||||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = _this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
name: 'node-secondary-edit-point',
|
||||||
index: i,
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: _this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
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++) {
|
// for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
// let entity = that.sdk.viewer.entities.add({
|
// let entity = this.sdk.viewer.entities.add({
|
||||||
// name: 'node-secondary-edit-point',
|
// name: 'node-secondary-edit-point',
|
||||||
// index: i,
|
// 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: {
|
// billboard: {
|
||||||
// image: that.getSourceRootPath() + '/img/point.png',
|
// image: this.getSourceRootPath() + '/img/point.png',
|
||||||
// width: 15,
|
// width: 15,
|
||||||
// height: 15,
|
// height: 15,
|
||||||
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
@ -2266,17 +1854,17 @@ class AttackArrowObject extends Base {
|
|||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static closeNodeEdit(that) {
|
closeNodeEdit() {
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event && that.event.destroy()
|
this.event && this.event.destroy()
|
||||||
that.tip && that.tip.destroy()
|
this.tip && this.tip.destroy()
|
||||||
that.tip = null
|
this.tip = null
|
||||||
|
|
||||||
for (let i = 0; i < that.nodePoints.length; i++) {
|
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||||
}
|
}
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
that.picking = true
|
this.picking = true
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(v) {
|
setPosition(v) {
|
||||||
@ -2679,8 +2267,8 @@ class AttackArrowObject extends Base {
|
|||||||
|
|
||||||
// 计算投影面积
|
// 计算投影面积
|
||||||
if (!this.spreadState) {
|
if (!this.spreadState) {
|
||||||
this.options.areaByMeter = this.computeArea(pos84)
|
this.areaByMeter = this.computeArea(pos84)
|
||||||
this.areaUnit = this.areaUnit
|
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||||
}
|
}
|
||||||
return fromDegreesArray
|
return fromDegreesArray
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class Layer extends BaseLayer {
|
|||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
this.object = {}
|
this.object = {}
|
||||||
this.options.host = this.options.host || getHost()
|
this.options.host = this.options.host || getHost()
|
||||||
|
this.on()
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
@ -24,21 +24,7 @@ class Layer extends BaseLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on() {
|
on() {
|
||||||
return this.add()
|
return this.loadLayer(this.options)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadLayer(data) {
|
async loadLayer(data) {
|
||||||
@ -64,11 +50,11 @@ class Layer extends BaseLayer {
|
|||||||
Cesium.Math.toRadians(this.object.north)
|
Cesium.Math.toRadians(this.object.north)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
// if (this.object.scheme_name === "GeographicTilingScheme") {
|
// if (this.object.schemaName === "GeographicTilingScheme") {
|
||||||
// console.log("添加GeographicTilingScheme")
|
// console.log("添加GeographicTilingScheme")
|
||||||
// params.tilingScheme = new Cesium.GeographicTilingScheme()
|
// params.tilingScheme = new Cesium.GeographicTilingScheme()
|
||||||
// }
|
// }
|
||||||
// if (this.object.scheme_name === "amapMercatorTilingScheme") {
|
// if (this.object.schemaName === "amapMercatorTilingScheme") {
|
||||||
// console.log("添加amapMercatorTilingScheme")
|
// console.log("添加amapMercatorTilingScheme")
|
||||||
// params.tilingScheme = this.amapMercatorTilingScheme()
|
// params.tilingScheme = this.amapMercatorTilingScheme()
|
||||||
// }
|
// }
|
||||||
@ -80,19 +66,19 @@ class Layer extends BaseLayer {
|
|||||||
// } else {
|
// } else {
|
||||||
// tms = new Cesium.UrlTemplateImageryProvider(params)
|
// tms = new Cesium.UrlTemplateImageryProvider(params)
|
||||||
// }
|
// }
|
||||||
switch (this.object.scheme_name) {
|
switch (this.object.schemaName) {
|
||||||
case "amapMercatorTilingScheme":
|
case "amapMercatorTilingScheme":
|
||||||
params.tilingScheme = this.amapMercatorTilingScheme()
|
params.tilingScheme = this.amapMercatorTilingScheme()
|
||||||
break;
|
break;
|
||||||
case "":
|
case "":
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
params.tilingScheme = new Cesium[this.object.scheme_name]()
|
params.tilingScheme = new Cesium[this.object.schemaName]()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (this.object.load_method) {
|
switch (this.object.load_method) {
|
||||||
case "tms":
|
case "tms":
|
||||||
if(this.object.url.endsWith("tilemapresource.xml")){
|
if (this.object.url.endsWith("tilemapresource.xml")) {
|
||||||
let arr = this.object.url.split("/")
|
let arr = this.object.url.split("/")
|
||||||
arr.pop()
|
arr.pop()
|
||||||
let url = arr.join("/")
|
let url = arr.join("/")
|
||||||
@ -116,7 +102,7 @@ class Layer extends BaseLayer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.sdk || !this.sdk.viewer) {
|
if (!this.sdk || !this.sdk.viewer) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.options.hasOwnProperty("layer_index")) {
|
if (this.options.hasOwnProperty("layer_index")) {
|
||||||
@ -137,7 +123,7 @@ class Layer extends BaseLayer {
|
|||||||
this.alpha = this.options.alpha
|
this.alpha = this.options.alpha
|
||||||
this.brightness = this.options.brightness
|
this.brightness = this.options.brightness
|
||||||
|
|
||||||
if(this.options.show) {
|
if (this.options.show) {
|
||||||
setSplitDirection(0, this.options.id)
|
setSplitDirection(0, this.options.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ class BIM extends BaseTileset {
|
|||||||
this.exportProperty(this.exportStateArray)
|
this.exportProperty(this.exportStateArray)
|
||||||
}
|
}
|
||||||
this.features = new Map()
|
this.features = new Map()
|
||||||
|
this.on()
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
|
@ -32,6 +32,7 @@ class Tileset extends BaseTileset {
|
|||||||
constructor(earth, options = {}, _Dialog = {}) {
|
constructor(earth, options = {}, _Dialog = {}) {
|
||||||
super(earth, options)
|
super(earth, options)
|
||||||
this.picking = false
|
this.picking = false
|
||||||
|
this.on()
|
||||||
this.Dialog = _Dialog
|
this.Dialog = _Dialog
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
this._EventBinding = new EventBinding()
|
this._EventBinding = new EventBinding()
|
||||||
@ -42,7 +43,7 @@ class Tileset extends BaseTileset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on() {
|
on() {
|
||||||
return this.add()
|
return this.loadTileset(this.options)
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
|
@ -74,31 +74,6 @@ class BaseTileset extends BaseSource {
|
|||||||
this.editObj.controllerCallBack = this.rotationEditingCallBack
|
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() {
|
loadSceneTree() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -469,7 +444,7 @@ class BaseTileset extends BaseSource {
|
|||||||
|
|
||||||
|
|
||||||
on() {
|
on() {
|
||||||
return this.add()
|
return this.loadTileset(this.options)
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaultValue() {
|
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.width=3 {number} 边框宽
|
||||||
* @param options.line.color="#ff000080" {string} 边框颜色
|
* @param options.line.color="#ff000080" {string} 边框颜色
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param options.areaUnit='平方米' {string} 面积单位
|
|
||||||
* @param options.customView {object} 默认视角
|
* @param options.customView {object} 默认视角
|
||||||
* @param options.customView.orientation {object} 默认视角方位
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
* @param options.customView.orientation.heading {number} 航向角
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
@ -87,7 +86,6 @@ class CircleObject extends Base {
|
|||||||
this.options.line = options.line || {}
|
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.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.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
|
||||||
options.label = options.label || {}
|
options.label = options.label || {}
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
this.options.label = {
|
this.options.label = {
|
||||||
@ -108,13 +106,13 @@ class CircleObject extends Base {
|
|||||||
this.options.attribute = options.attribute || {}
|
this.options.attribute = options.attribute || {}
|
||||||
this.options.attribute.link = this.options.attribute.link || {}
|
this.options.attribute.link = this.options.attribute.link || {}
|
||||||
this.options.attribute.link.content = this.options.attribute.link.content || []
|
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 || []
|
delete this.options.attribute.camera
|
||||||
this.options.attribute.camera = this.options.attribute.camera || {}
|
delete this.options.attribute.vr
|
||||||
this.options.attribute.camera.content = this.options.attribute.camera.content || []
|
delete this.options.attribute.goods
|
||||||
this.options.attribute.goods = this.options.attribute.goods || {}
|
|
||||||
this.options.attribute.goods.content = this.options.attribute.goods.content || []
|
|
||||||
this.options.attributeType = options.attributeType || 'richText'
|
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
this.nodePoints = []
|
this.nodePoints = []
|
||||||
this.operate = {}
|
this.operate = {}
|
||||||
@ -140,7 +138,7 @@ class CircleObject extends Base {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let heightModeName = ''
|
let heightModeName = ''
|
||||||
CircleObject.closeNodeEdit(this)
|
this.closeNodeEdit()
|
||||||
let ground = false
|
let ground = false
|
||||||
let disabled = false
|
let disabled = false
|
||||||
this.renewPositions()
|
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() {
|
get labelShow() {
|
||||||
return this.options.label.show
|
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) {
|
static create(that) {
|
||||||
let fromDegreesArray = that.createCircle(that.options.center, that.options.radius)
|
let fromDegreesArray = that.createCircle(that.options.center, that.options.radius)
|
||||||
let ground
|
let ground
|
||||||
@ -914,9 +559,10 @@ class CircleObject extends Base {
|
|||||||
ground = true
|
ground = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if (!that.options.label.position) {
|
// 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 }
|
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)
|
let material = Cesium.Color.fromCssColorString(that.options.color)
|
||||||
if (that.sdk.viewer.scene.mode === 2) {
|
if (that.sdk.viewer.scene.mode === 2) {
|
||||||
@ -930,7 +576,7 @@ class CircleObject extends Base {
|
|||||||
for (let i = 0; i < fromDegreesArray.length; i += 2) {
|
for (let i = 0; i < fromDegreesArray.length; i += 2) {
|
||||||
fromDegreesArray2.push(fromDegreesArray[i], fromDegreesArray[i + 1], that.options.center.alt + height)
|
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)
|
that.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
||||||
positionsA = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
positionsA = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
that.entity = that.sdk.viewer.entities.add({
|
that.entity = that.sdk.viewer.entities.add({
|
||||||
@ -953,23 +599,8 @@ class CircleObject extends Base {
|
|||||||
})
|
})
|
||||||
that.sdk._entityZIndex++
|
that.sdk._entityZIndex++
|
||||||
CircleObject.createLabel(that)
|
CircleObject.createLabel(that)
|
||||||
that.options.areaByMeter = Number((Cesium.Math.PI * that.options.radius * that.options.radius).toFixed(2));
|
that.areaByMeter = Number((Cesium.Math.PI * that.options.radius * that.options.radius).toFixed(2));
|
||||||
switch (that.options['area-unit']) {
|
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||||
case '平方米':
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
break;
|
|
||||||
case '平方千米':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
||||||
break;
|
|
||||||
case '亩':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
||||||
break;
|
|
||||||
case '公顷':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
}
|
|
||||||
|
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
if (that.options.show) {
|
if (that.options.show) {
|
||||||
@ -995,12 +626,12 @@ class CircleObject extends Base {
|
|||||||
scaleByDistance: that.options.label.scaleByDistance,
|
scaleByDistance: that.options.label.scaleByDistance,
|
||||||
near: that.options.label.near,
|
near: that.options.label.near,
|
||||||
far: that.options.label.far,
|
far: that.options.label.far,
|
||||||
ground: that.options.label.ground,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑框
|
// 编辑框
|
||||||
async edit(state) {
|
async edit(state) {
|
||||||
|
return
|
||||||
let _this = this
|
let _this = this
|
||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
|
||||||
@ -1492,8 +1123,6 @@ class CircleObject extends Base {
|
|||||||
this.name = this.originalOptions.name
|
this.name = this.originalOptions.name
|
||||||
this.radius = this.originalOptions.radius
|
this.radius = this.originalOptions.radius
|
||||||
this.color = this.originalOptions.color
|
this.color = this.originalOptions.color
|
||||||
this.area = this.originalOptions.area
|
|
||||||
this.areaUnit = this.originalOptions['area-unit']
|
|
||||||
this.labelShow = this.originalOptions.label.show
|
this.labelShow = this.originalOptions.label.show
|
||||||
this.labelFontSize = this.originalOptions.label.fontSize
|
this.labelFontSize = this.originalOptions.label.fontSize
|
||||||
this.labelFontFamily = this.originalOptions.label.fontFamily
|
this.labelFontFamily = this.originalOptions.label.fontFamily
|
||||||
@ -1509,12 +1138,6 @@ class CircleObject extends Base {
|
|||||||
this.lineColor = this.originalOptions.line.color
|
this.lineColor = this.originalOptions.line.color
|
||||||
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
||||||
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
|
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
|
this.heightMode = this.originalOptions.heightMode
|
||||||
|
|
||||||
@ -1554,51 +1177,6 @@ class CircleObject extends Base {
|
|||||||
await syncData(this.sdk, this.options.id)
|
await syncData(this.sdk, this.options.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
_addLink() {
|
|
||||||
// document.getElementsByClassName
|
|
||||||
if (this._DialogObject._element.content.getElementsByClassName('link_add')[0].value) {
|
|
||||||
this.options.attribute.link.content.push({
|
|
||||||
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 }
|
positions: { ...this.options.center }
|
||||||
}
|
}
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
|
|
||||||
|
if(this._positionEditingCallback) {
|
||||||
|
this._positionEditingCallback()
|
||||||
|
this._positionEditingCallback = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.event.mouse_right((movement, cartesian) => {
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
@ -1866,88 +1449,104 @@ class CircleObject extends Base {
|
|||||||
return this.operate.positionEditing
|
return this.operate.positionEditing
|
||||||
}
|
}
|
||||||
|
|
||||||
static nodeEdit(that, cb = () => { }) {
|
openPositionEditing(cd) {
|
||||||
that.positionEditing = false
|
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()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
} else {
|
} else {
|
||||||
that.event && that.event.destroy()
|
let _this = this
|
||||||
that.event = new MouseEvent(that.sdk)
|
this.event && this.event.destroy()
|
||||||
|
this.event = new MouseEvent(this.sdk)
|
||||||
YJ.Measure.SetMeasureStatus(true)
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
that.tip = new MouseTip('左键确认,右键取消', that.sdk)
|
this.tip = new MouseTip('左键确认,右键取消', this.sdk)
|
||||||
that.event = new MouseEvent(that.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
let selectPoint
|
let selectPoint
|
||||||
let originalPosition
|
let originalPosition
|
||||||
let newpositions = []
|
let newpositions = []
|
||||||
let fromDegreesArray = []
|
let fromDegreesArray = []
|
||||||
let endpoint = { ...that.options.center }
|
let endpoint = { ...this.options.center }
|
||||||
let moveRadius = null
|
let moveRadius = null
|
||||||
let entity
|
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
|
this.entity.polyline.clampToGround = true
|
||||||
that.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
this.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
||||||
that.entity.polygon.perPositionHeight = false
|
this.entity.polygon.perPositionHeight = false
|
||||||
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||||
return new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray))
|
return new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray))
|
||||||
}, false)
|
}, false)
|
||||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||||
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
}, false)
|
}, false)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||||
that
|
this
|
||||||
.getClampToHeight({
|
.getClampToHeight({
|
||||||
lng: that.options.center.lng,
|
lng: this.options.center.lng,
|
||||||
lat: that.options.center.lat
|
lat: this.options.center.lat
|
||||||
}, objectsToExclude)
|
}, objectsToExclude)
|
||||||
.then(height => {
|
.then(height => {
|
||||||
that.label.position = [
|
this.label.position = [
|
||||||
that.options.center.lng,
|
this.options.center.lng,
|
||||||
that.options.center.lat,
|
this.options.center.lat,
|
||||||
height
|
height
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
that.event.mouse_left((movement, cartesian) => {
|
this.event.mouse_left((movement, cartesian) => {
|
||||||
if (entity) {
|
if (entity) {
|
||||||
that.sdk.viewer.entities.remove(entity)
|
this.sdk.viewer.entities.remove(entity)
|
||||||
entity = null
|
entity = null
|
||||||
}
|
}
|
||||||
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
let radius = that.computeDistance2([that.options.center, endpoint])
|
let radius = this.computeDistance2([this.options.center, endpoint])
|
||||||
that.radius = radius
|
this.radius = radius
|
||||||
|
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event.destroy()
|
this.event.destroy()
|
||||||
that.tip.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) {
|
if (entity) {
|
||||||
that.sdk.viewer.entities.remove(entity)
|
this.sdk.viewer.entities.remove(entity)
|
||||||
entity = null
|
entity = null
|
||||||
}
|
}
|
||||||
|
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event.destroy()
|
this.event.destroy()
|
||||||
that.tip.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)
|
entity && (entity.show = true)
|
||||||
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
moveRadius = that.computeDistance2([that.options.center, endpoint])
|
moveRadius = this.computeDistance2([this.options.center, endpoint])
|
||||||
fromDegreesArray = that.createCircle(that.options.center, moveRadius)
|
fromDegreesArray = this.createCircle(this.options.center, moveRadius)
|
||||||
that.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.endPosition.x,
|
movement.endPosition.x,
|
||||||
movement.endPosition.y
|
movement.endPosition.y
|
||||||
@ -1956,28 +1555,28 @@ class CircleObject extends Base {
|
|||||||
createNodePoints()
|
createNodePoints()
|
||||||
}, 200);
|
}, 200);
|
||||||
async function createNodePoints() {
|
async function createNodePoints() {
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||||
let height = await that.getClampToHeight(that.options.center, objectsToExclude)
|
let height = await _this.getClampToHeight(_this.options.center, objectsToExclude)
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = _this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: _this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
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({
|
new Cesium.Entity({
|
||||||
show: false,
|
show: false,
|
||||||
position: new Cesium.CallbackProperty((e) => {
|
position: new Cesium.CallbackProperty((e) => {
|
||||||
if (endpoint) {
|
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)
|
return Cesium.Cartesian3.fromDegrees(c.lng, c.lat, endpoint.alt)
|
||||||
} else {
|
} else {
|
||||||
return Cesium.Cartesian3()
|
return Cesium.Cartesian3()
|
||||||
@ -2000,7 +1599,7 @@ class CircleObject extends Base {
|
|||||||
},
|
},
|
||||||
polyline: {
|
polyline: {
|
||||||
positions: new Cesium.CallbackProperty((e) => {
|
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),
|
}, false),
|
||||||
width: 2,
|
width: 2,
|
||||||
material:
|
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)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event && that.event.destroy()
|
this.event && this.event.destroy()
|
||||||
that.tip && that.tip.destroy()
|
this.tip && this.tip.destroy()
|
||||||
that.tip = null
|
this.tip = null
|
||||||
|
|
||||||
for (let i = 0; i < that.nodePoints.length; i++) {
|
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||||
}
|
}
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
that.picking = true
|
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.areaByMeter = Number((Cesium.Math.PI * this.options.radius * this.options.radius).toFixed(2))
|
||||||
this.areaUnit = this.areaUnit
|
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||||
return fromDegreesArray
|
return fromDegreesArray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,12 +13,11 @@ import {
|
|||||||
} from '../../../Global/cluster/cluster'
|
} from '../../../Global/cluster/cluster'
|
||||||
|
|
||||||
class LabelObject extends Base {
|
class LabelObject extends Base {
|
||||||
#updateBillboardImageTimeout
|
|
||||||
#canvas = document.createElement('canvas')
|
|
||||||
#canvas2 = document.createElement('canvas')
|
|
||||||
constructor(sdk, options = {}, model) {
|
constructor(sdk, options = {}, model) {
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
this.model = model
|
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.near = options.near || options.near === 0 ? options.near : 2000
|
||||||
this.options.far = options.far || options.far === 0 ? options.far : 100000
|
this.options.far = options.far || options.far === 0 ? options.far : 100000
|
||||||
this.options.scaleByDistance = options.scaleByDistance || false
|
this.options.scaleByDistance = options.scaleByDistance || false
|
||||||
@ -69,7 +68,7 @@ class LabelObject extends Base {
|
|||||||
|
|
||||||
let id = this.options.id + '-label'
|
let id = this.options.id + '-label'
|
||||||
let oldEntity = this.sdk.viewer.entities.getById(id)
|
let oldEntity = this.sdk.viewer.entities.getById(id)
|
||||||
if(oldEntity) {
|
if (oldEntity) {
|
||||||
this.sdk.viewer.entities.remove(oldEntity)
|
this.sdk.viewer.entities.remove(oldEntity)
|
||||||
}
|
}
|
||||||
this.entity = this.sdk.viewer.entities.add({
|
this.entity = this.sdk.viewer.entities.add({
|
||||||
@ -492,8 +491,8 @@ class LabelObject extends Base {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
getcanvas() {
|
getcanvas() {
|
||||||
const ctx = this.#canvas.getContext('2d')
|
const ctx = this._canvas.getContext('2d')
|
||||||
ctx.clearRect(0, 0, this.#canvas.width, this.#canvas.height);
|
ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
|
||||||
ctx.font = this.options.fontSize + 'px ' + this.font
|
ctx.font = this.options.fontSize + 'px ' + this.font
|
||||||
let texts = this.options.text.split('\n')
|
let texts = this.options.text.split('\n')
|
||||||
let canvasWidth = 0
|
let canvasWidth = 0
|
||||||
@ -511,8 +510,8 @@ class LabelObject extends Base {
|
|||||||
if (canvasWidth < this.options.lineWidth) {
|
if (canvasWidth < this.options.lineWidth) {
|
||||||
canvasWidth = this.options.lineWidth
|
canvasWidth = this.options.lineWidth
|
||||||
}
|
}
|
||||||
this.#canvas.width = canvasWidth
|
this._canvas.width = canvasWidth
|
||||||
this.#canvas.height = this.options.pixelOffset + canvasHeight
|
this._canvas.height = this.options.pixelOffset + canvasHeight
|
||||||
const linearGradient = ctx.createLinearGradient(
|
const linearGradient = ctx.createLinearGradient(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -559,14 +558,14 @@ class LabelObject extends Base {
|
|||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
ctx.closePath()
|
ctx.closePath()
|
||||||
|
|
||||||
const ctx2 = this.#canvas2.getContext('2d')
|
const ctx2 = this._canvas2.getContext('2d')
|
||||||
this.#canvas2.width = this.#canvas.width + 10
|
this._canvas2.width = this._canvas.width + 10
|
||||||
this.#canvas2.height = this.#canvas.height + 10
|
this._canvas2.height = this._canvas.height + 10
|
||||||
ctx2.drawImage(this.#canvas, 5, 5);
|
ctx2.drawImage(this._canvas, 5, 5);
|
||||||
|
|
||||||
// const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
// const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
// ctx.putImageData(imageData, 40, 40);
|
// ctx.putImageData(imageData, 40, 40);
|
||||||
return this.#canvas2.toDataURL("image/png")
|
return this._canvas2.toDataURL("image/png")
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
@ -28,7 +28,6 @@ class PincerArrowObject extends Base {
|
|||||||
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param options.areaUnit='平方米' {string} 面积单位
|
|
||||||
* @param options.line {object} 边框
|
* @param options.line {object} 边框
|
||||||
* @param options.line.width=2 {string} 边框宽
|
* @param options.line.width=2 {string} 边框宽
|
||||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {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 = options.line || {}
|
||||||
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
|
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.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.height = options.height
|
||||||
this.options.loop = options.loop || false
|
this.options.loop = options.loop || false
|
||||||
this.options.spreadState = options.spreadState || false
|
this.options.spreadState = options.spreadState || false
|
||||||
@ -113,13 +111,10 @@ class PincerArrowObject extends Base {
|
|||||||
this.options.attribute = options.attribute || {}
|
this.options.attribute = options.attribute || {}
|
||||||
this.options.attribute.link = this.options.attribute.link || {}
|
this.options.attribute.link = this.options.attribute.link || {}
|
||||||
this.options.attribute.link.content = this.options.attribute.link.content || []
|
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 || []
|
delete this.options.attribute.camera
|
||||||
this.options.attribute.vr = this.options.attribute.vr || {}
|
delete this.options.attribute.vr
|
||||||
this.options.attribute.vr.content = this.options.attribute.vr.content || []
|
delete this.options.attribute.goods
|
||||||
this.options.attribute.goods = this.options.attribute.goods || {}
|
|
||||||
this.options.attribute.goods.content = this.options.attribute.goods.content || []
|
|
||||||
this.options.attributeType = options.attributeType || 'richText'
|
|
||||||
|
|
||||||
if (!this.options.positions || this.options.positions.length < 5) {
|
if (!this.options.positions || this.options.positions.length < 5) {
|
||||||
this._error = '双箭头最少需要五个坐标!'
|
this._error = '双箭头最少需要五个坐标!'
|
||||||
@ -208,7 +203,7 @@ class PincerArrowObject extends Base {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let heightModeName = ''
|
let heightModeName = ''
|
||||||
PincerArrowObject.closeNodeEdit(this)
|
this.closeNodeEdit()
|
||||||
let ground = false
|
let ground = false
|
||||||
let disabled = false
|
let disabled = false
|
||||||
this.renewPositions()
|
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() {
|
get labelShow() {
|
||||||
return this.options.label.show
|
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) {
|
static create(that) {
|
||||||
let positions = that.options.positions
|
let positions = that.options.positions
|
||||||
let fromDegreesArray = []
|
let fromDegreesArray = []
|
||||||
@ -939,9 +581,10 @@ class PincerArrowObject extends Base {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!that.options.label.position) {
|
// 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.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||||
}
|
|
||||||
|
|
||||||
let fromDegreesArray2 = []
|
let fromDegreesArray2 = []
|
||||||
for (let i = 0; i < points[0].length; i++) {
|
for (let i = 0; i < points[0].length; i++) {
|
||||||
@ -959,7 +602,7 @@ class PincerArrowObject extends Base {
|
|||||||
color: that.options.color
|
color: that.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
that.options.label.ground = ground
|
// that.options.label.ground = ground
|
||||||
|
|
||||||
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
||||||
|
|
||||||
@ -987,23 +630,8 @@ class PincerArrowObject extends Base {
|
|||||||
for (let i = 0; i < positionsA.length; i++) {
|
for (let i = 0; i < positionsA.length; i++) {
|
||||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||||
}
|
}
|
||||||
that.options.areaByMeter = that.computeArea(pos84);
|
that.areaByMeter = that.computeArea(pos84);
|
||||||
switch (that.options['area-unit']) {
|
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||||
case '平方米':
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
break;
|
|
||||||
case '平方千米':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
|
||||||
break;
|
|
||||||
case '亩':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
|
||||||
break;
|
|
||||||
case '公顷':
|
|
||||||
that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
that.options.area = that.options.areaByMeter
|
|
||||||
}
|
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
if (that.options.show) {
|
if (that.options.show) {
|
||||||
|
|
||||||
@ -1030,12 +658,13 @@ class PincerArrowObject extends Base {
|
|||||||
scaleByDistance: that.options.label.scaleByDistance,
|
scaleByDistance: that.options.label.scaleByDistance,
|
||||||
near: that.options.label.near,
|
near: that.options.label.near,
|
||||||
far: that.options.label.far,
|
far: that.options.label.far,
|
||||||
ground: that.options.label.ground,
|
// ground: that.options.label.ground,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑框
|
// 编辑框
|
||||||
async edit(state) {
|
async edit(state) {
|
||||||
|
return
|
||||||
if (this._error) {
|
if (this._error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1534,8 +1163,6 @@ class PincerArrowObject extends Base {
|
|||||||
this.color = this.originalOptions.color
|
this.color = this.originalOptions.color
|
||||||
this.lineColor = this.originalOptions.line.color
|
this.lineColor = this.originalOptions.line.color
|
||||||
this.lineWidth = this.originalOptions.line.width
|
this.lineWidth = this.originalOptions.line.width
|
||||||
this.area = this.originalOptions.area
|
|
||||||
this.areaUnit = this.originalOptions['area-unit']
|
|
||||||
this.labelShow = this.originalOptions.label.show
|
this.labelShow = this.originalOptions.label.show
|
||||||
this.labelColor = this.originalOptions.label.color
|
this.labelColor = this.originalOptions.label.color
|
||||||
this.labelFontSize = this.originalOptions.label.fontSize
|
this.labelFontSize = this.originalOptions.label.fontSize
|
||||||
@ -1548,12 +1175,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.labelLineColor = this.originalOptions.label.lineColor
|
this.labelLineColor = this.originalOptions.label.lineColor
|
||||||
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
||||||
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
|
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++) {
|
for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
if (this._elms.lng && this._elms.lng[i]) {
|
if (this._elms.lng && this._elms.lng[i]) {
|
||||||
@ -1607,51 +1229,6 @@ class PincerArrowObject extends Base {
|
|||||||
await syncData(this.sdk, this.options.id)
|
await syncData(this.sdk, this.options.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
_addLink() {
|
|
||||||
// document.getElementsByClassName
|
|
||||||
if (this._DialogObject._element.content.getElementsByClassName('link_add')[0].value) {
|
|
||||||
this.options.attribute.link.content.push({
|
|
||||||
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]
|
positions: [...this.positions]
|
||||||
}
|
}
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
|
|
||||||
|
if(this._positionEditingCallback) {
|
||||||
|
this._positionEditingCallback()
|
||||||
|
this._positionEditingCallback = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.event.mouse_right((movement, cartesian) => {
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
@ -1954,208 +1536,122 @@ class PincerArrowObject extends Base {
|
|||||||
get positionEditing() {
|
get positionEditing() {
|
||||||
return this.operate.positionEditing
|
return this.operate.positionEditing
|
||||||
}
|
}
|
||||||
|
openPositionEditing(cd) {
|
||||||
static EventBinding(that, elements) {
|
this.positionEditing = true
|
||||||
for (let i = 0; i < elements.length; i++) {
|
this._positionEditingCallback = cd
|
||||||
let Event = []
|
|
||||||
let isEvent = false
|
|
||||||
let removeName = []
|
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
for (let m of elements[i].attributes) {
|
get areaChangeCallBack() {
|
||||||
switch (m.name) {
|
return this._areaChangeCallBack
|
||||||
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) {
|
set areaChangeCallBack (cd) {
|
||||||
let ventType = 'input'
|
this._areaChangeCallBack = cd
|
||||||
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)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static nodeEdit(that, cb = () => { }) {
|
|
||||||
that.positionEditing = false
|
nodeEdit(cb = () => { }) {
|
||||||
|
this.positionEditing = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (YJ.Measure.GetMeasureStatus()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
cb('上一次测量未结束')
|
cb('上一次测量未结束')
|
||||||
} else {
|
} else {
|
||||||
that.removeAnimate()
|
this.removeAnimate()
|
||||||
|
let _this = this
|
||||||
YJ.Measure.SetMeasureStatus(true)
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||||
that.event = new MouseEvent(that.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
let selectPoint
|
let selectPoint
|
||||||
let originalPosition
|
let originalPosition
|
||||||
let optionsPositions = [...that.options.positions]
|
let optionsPositions = [...this.options.positions]
|
||||||
|
|
||||||
let leftEvent = (movement, cartesian) => {
|
let leftEvent = (movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
optionsPositions[selectPoint.index] = that.options.positions[selectPoint.index]
|
optionsPositions[selectPoint.index] = this.options.positions[selectPoint.index]
|
||||||
let index = 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',
|
name: 'node-secondary-edit-point',
|
||||||
index: index,
|
index: index,
|
||||||
position: Cesium.Cartesian3.fromDegrees(optionsPositions[selectPoint.index].lng, optionsPositions[selectPoint.index].lat, optionsPositions[selectPoint.index].alt),
|
position: Cesium.Cartesian3.fromDegrees(optionsPositions[selectPoint.index].lng, optionsPositions[selectPoint.index].lat, optionsPositions[selectPoint.index].alt),
|
||||||
billboard: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||||
selectPoint = null
|
selectPoint = null
|
||||||
that.tip.set_text('请选择一个顶点,右键取消')
|
this.tip.set_text('请选择一个顶点,右键取消')
|
||||||
}
|
}
|
||||||
else {
|
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') {
|
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||||
selectPoint = pick.id
|
selectPoint = pick.id
|
||||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||||
that.nodePoints.splice(pick.id.index, 1)
|
this.nodePoints.splice(pick.id.index, 1)
|
||||||
that.sdk.viewer.entities.remove(pick.id)
|
this.sdk.viewer.entities.remove(pick.id)
|
||||||
that.tip.set_text('左键确定,右键取消')
|
this.tip.set_text('左键确定,右键取消')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.renewPositions()
|
this.renewPositions()
|
||||||
that.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.position.x,
|
movement.position.x,
|
||||||
movement.position.y
|
movement.position.y
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
let rightEvent = () => {
|
let rightEvent = () => {
|
||||||
that.event.mouse_move(() => { })
|
this.event.mouse_move(() => { })
|
||||||
that.event.mouse_left(() => { })
|
this.event.mouse_left(() => { })
|
||||||
that.event.mouse_right(() => { })
|
this.event.mouse_right(() => { })
|
||||||
that.event.gesture_pinck_start(() => { })
|
this.event.gesture_pinck_start(() => { })
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
optionsPositions[selectPoint.index] = originalPosition
|
optionsPositions[selectPoint.index] = originalPosition
|
||||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||||
}
|
}
|
||||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||||
}
|
}
|
||||||
cb(null, optionsPositions)
|
cb(null, optionsPositions)
|
||||||
}
|
}
|
||||||
that.options.positions = [...optionsPositions]
|
this.options.positions = [...optionsPositions]
|
||||||
that.heightMode = that.heightMode
|
this.heightMode = this.heightMode
|
||||||
that.previous = null
|
this.previous = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
that.entity.polyline.clampToGround = true
|
this.entity.polyline.clampToGround = true
|
||||||
that.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
this.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
||||||
that.entity.polygon.perPositionHeight = false
|
this.entity.polygon.perPositionHeight = false
|
||||||
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||||
return new Cesium.PolygonHierarchy(that.positionsH)
|
return new Cesium.PolygonHierarchy(_this.positionsH)
|
||||||
}, false)
|
}, false)
|
||||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||||
return [...that.positionsH, that.positionsH[0], that.positionsH[1]]
|
return [..._this.positionsH, _this.positionsH[0], _this.positionsH[1]]
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
setTimeout(() => {
|
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) {
|
if (selectPoint) {
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
that.renewPositions()
|
this.renewPositions()
|
||||||
}
|
}
|
||||||
that.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.endPosition.x,
|
movement.endPosition.x,
|
||||||
movement.endPosition.y
|
movement.endPosition.y
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||||
let startTime = new Date()
|
let startTime = new Date()
|
||||||
let pos = {
|
let pos = {
|
||||||
position: {
|
position: {
|
||||||
@ -2163,7 +1659,7 @@ class PincerArrowObject extends Base {
|
|||||||
y: (movement.position1.y + movement.position2.y) / 2
|
y: (movement.position1.y + movement.position2.y) / 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.event.gesture_pinck_end(() => {
|
this.event.gesture_pinck_end(() => {
|
||||||
let endTime = new Date()
|
let endTime = new Date()
|
||||||
if (endTime - startTime >= 500) {
|
if (endTime - startTime >= 500) {
|
||||||
// 长按取消
|
// 长按取消
|
||||||
@ -2178,23 +1674,23 @@ class PincerArrowObject extends Base {
|
|||||||
|
|
||||||
let points = [[]]
|
let points = [[]]
|
||||||
let pos84 = []
|
let pos84 = []
|
||||||
for (let i = 0; i < that.positionsH.length; i++) {
|
for (let i = 0; i < this.positionsH.length; i++) {
|
||||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||||
pos84.push(position)
|
pos84.push(position)
|
||||||
points[0].push([position.lng, position.lat])
|
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])
|
points[0].push([position.lng, position.lat])
|
||||||
let polygon = turf.polygon(points)
|
let polygon = turf.polygon(points)
|
||||||
let centroid = turf.pointOnFeature(polygon)
|
let centroid = turf.pointOnFeature(polygon)
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||||
that
|
this
|
||||||
.getClampToHeight({
|
.getClampToHeight({
|
||||||
lng: centroid.geometry.coordinates[0],
|
lng: centroid.geometry.coordinates[0],
|
||||||
lat: centroid.geometry.coordinates[1]
|
lat: centroid.geometry.coordinates[1]
|
||||||
}, objectsToExclude)
|
}, objectsToExclude)
|
||||||
.then(height => {
|
.then(height => {
|
||||||
that.label.position = [
|
this.label.position = [
|
||||||
centroid.geometry.coordinates[0],
|
centroid.geometry.coordinates[0],
|
||||||
centroid.geometry.coordinates[1],
|
centroid.geometry.coordinates[1],
|
||||||
height
|
height
|
||||||
@ -2203,39 +1699,39 @@ class PincerArrowObject extends Base {
|
|||||||
createNodePoints()
|
createNodePoints()
|
||||||
}, 200);
|
}, 200);
|
||||||
async function createNodePoints() {
|
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++) {
|
for (let i = 0; i < optionsPositions.length; i++) {
|
||||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = _this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
name: 'node-secondary-edit-point',
|
||||||
index: i,
|
index: i,
|
||||||
position: Cesium.Cartesian3.fromDegrees(optionsPositions[i].lng, optionsPositions[i].lat, height),
|
position: Cesium.Cartesian3.fromDegrees(optionsPositions[i].lng, optionsPositions[i].lat, height),
|
||||||
billboard: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: _this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
that.nodePoints.push(entity)
|
_this.nodePoints.push(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static closeNodeEdit(that) {
|
closeNodeEdit() {
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event && that.event.destroy()
|
this.event && this.event.destroy()
|
||||||
that.tip && that.tip.destroy()
|
this.tip && this.tip.destroy()
|
||||||
that.tip = null
|
this.tip = null
|
||||||
|
|
||||||
for (let i = 0; i < that.nodePoints.length; i++) {
|
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||||
}
|
}
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
that.picking = true
|
this.picking = true
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(v) {
|
setPosition(v) {
|
||||||
@ -2673,8 +2169,8 @@ class PincerArrowObject extends Base {
|
|||||||
|
|
||||||
// 计算投影面积
|
// 计算投影面积
|
||||||
if (!this.spreadState) {
|
if (!this.spreadState) {
|
||||||
this.options.areaByMeter = this.computeArea(pos84)
|
this.areaByMeter = this.computeArea(pos84)
|
||||||
this.areaUnit = this.areaUnit
|
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||||
}
|
}
|
||||||
return fromDegreesArray
|
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.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.text {string} 文字
|
* @param options.text {string} 文字
|
||||||
|
* @param options.color=#FFC107 {string} 颜色
|
||||||
* @param options.angle=0 {number} 旋转角度
|
* @param options.angle=0 {number} 旋转角度
|
||||||
* @param options.scale=1 {number} 缩放比例
|
* @param options.scale=1 {number} 缩放比例
|
||||||
* @param options.speed=1 {number} 文字滚动速度
|
* @param options.speed=1 {number} 文字滚动速度
|
||||||
@ -49,20 +50,21 @@ class GroundText extends Base {
|
|||||||
textArray.splice(70 - textArray.length)
|
textArray.splice(70 - textArray.length)
|
||||||
}
|
}
|
||||||
this.options.text = textArray.join('\n')
|
this.options.text = textArray.join('\n')
|
||||||
this.options.name = this.options.text
|
|
||||||
this.options.show =
|
this.options.show =
|
||||||
options.show || options.show === false ? options.show : true
|
options.show || options.show === false ? options.show : true
|
||||||
this.options.angle = options.angle || 0
|
this.options.angle = options.angle || 0
|
||||||
this.options.scale =
|
this.options.scale =
|
||||||
options.scale || options.scale === 0 ? options.scale : 1
|
options.scale || options.scale === 0 ? options.scale : 1
|
||||||
this.options.fontSize = options.fontSize || 20
|
// this.options.fontSize = options.fontSize || 20
|
||||||
this.options.duration =
|
// this.options.duration =
|
||||||
options.duration || options.duration === 0 ? options.duration : 50000
|
// options.duration || options.duration === 0 ? options.duration : 50000
|
||||||
this.options.speed =
|
this.options.speed =
|
||||||
options.speed || options.speed === 0 ? options.speed : 1
|
options.speed || options.speed === 0 ? options.speed : 1
|
||||||
this.options.color = options.color || '#FFC107'
|
this.options.color = options.color || '#FFC107'
|
||||||
this.options.position = options.position
|
this.options.position = options.position
|
||||||
|
|
||||||
|
delete this.options.name
|
||||||
|
|
||||||
if (!this.options.position && this.options.positions) {
|
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 }
|
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]);
|
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]);
|
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 =
|
let gap =
|
||||||
Math.abs(Math.cos((Math.PI / 180) * this.options.position.lat)) *
|
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 to = turf.point([lng2, lat]);
|
||||||
let distance2 = turf.rhumbDistance(from, to, options);
|
let distance2 = turf.rhumbDistance(from, to, options);
|
||||||
let latRadians = Cesium.Math.toRadians(this.options.position.lat)
|
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.options.scale = distance1 / distance2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.duration = 50000
|
||||||
this.entity
|
this.entity
|
||||||
this._positionEditing = false
|
this._positionEditing = false
|
||||||
this.Dialog = _Dialog
|
this.Dialog = _Dialog
|
||||||
@ -137,6 +140,9 @@ class GroundText extends Base {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return
|
||||||
|
}
|
||||||
get text() {
|
get text() {
|
||||||
return this.options.text
|
return this.options.text
|
||||||
}
|
}
|
||||||
@ -172,7 +178,7 @@ class GroundText extends Base {
|
|||||||
image: canvas.toDataURL('image/png'),
|
image: canvas.toDataURL('image/png'),
|
||||||
color: this.options.color,
|
color: this.options.color,
|
||||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||||
duration: this.options.duration / this.options.speed,
|
duration: this.duration / this.options.speed,
|
||||||
fltr: false,
|
fltr: false,
|
||||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||||
})
|
})
|
||||||
@ -219,26 +225,26 @@ class GroundText extends Base {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get duration() {
|
// get duration() {
|
||||||
return this.options.duration
|
// return this.options.duration
|
||||||
}
|
// }
|
||||||
|
|
||||||
set duration(v) {
|
// set duration(v) {
|
||||||
this.options.duration = v
|
// this.options.duration = v
|
||||||
let canvas = this.getcanvas()
|
// let canvas = this.getcanvas()
|
||||||
this.entity.rectangle.material = new Cesium.CustomMaterialSource({
|
// this.entity.rectangle.material = new Cesium.CustomMaterialSource({
|
||||||
image: canvas.toDataURL('image/png'),
|
// image: canvas.toDataURL('image/png'),
|
||||||
color: this.options.color,
|
// color: this.options.color,
|
||||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
// repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||||
duration: this.options.duration / this.options.speed,
|
// duration: this.options.duration / this.options.speed,
|
||||||
fltr: false,
|
// fltr: false,
|
||||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
// is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||||
})
|
// })
|
||||||
this._elms.duration &&
|
// this._elms.duration &&
|
||||||
this._elms.duration.forEach(item => {
|
// this._elms.duration.forEach(item => {
|
||||||
item.value = v
|
// item.value = v
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
get speed() {
|
get speed() {
|
||||||
return this.options.speed
|
return this.options.speed
|
||||||
}
|
}
|
||||||
@ -250,7 +256,7 @@ class GroundText extends Base {
|
|||||||
image: canvas.toDataURL('image/png'),
|
image: canvas.toDataURL('image/png'),
|
||||||
color: this.options.color,
|
color: this.options.color,
|
||||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||||
duration: this.options.duration / this.options.speed,
|
duration: this.duration / this.options.speed,
|
||||||
fltr: false,
|
fltr: false,
|
||||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : 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'),
|
image: canvas.toDataURL('image/png'),
|
||||||
color: this.options.color,
|
color: this.options.color,
|
||||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||||
duration: this.options.duration / this.options.speed,
|
duration: this.duration / this.options.speed,
|
||||||
fltr: false,
|
fltr: false,
|
||||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : 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'),
|
image: canvas.toDataURL('image/png'),
|
||||||
color: this.options.color,
|
color: this.options.color,
|
||||||
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
repeat: new Cesium.Cartesian2(1.0, 1.0),
|
||||||
duration: this.options.duration / this.options.speed,
|
duration: this.duration / this.options.speed,
|
||||||
fltr: false,
|
fltr: false,
|
||||||
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false
|
||||||
}),
|
}),
|
||||||
@ -505,6 +511,10 @@ class GroundText extends Base {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
if (this._positionEditingCallback) {
|
||||||
|
this._positionEditingCallback()
|
||||||
|
this._positionEditingCallback = null
|
||||||
|
}
|
||||||
if (this.event) {
|
if (this.event) {
|
||||||
this.event.mouse_move(() => { })
|
this.event.mouse_move(() => { })
|
||||||
this.event.mouse_left(() => { })
|
this.event.mouse_left(() => { })
|
||||||
@ -520,6 +530,11 @@ class GroundText extends Base {
|
|||||||
return this._positionEditing
|
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.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.nodePoints = []
|
this.nodePoints = []
|
||||||
this.entity
|
this.entity
|
||||||
this.options.instruct = options.instruct || ""
|
|
||||||
this.options.operatingPoint = options.operatingPoint || ""
|
delete this.options.name
|
||||||
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'
|
|
||||||
this.extrudedHeight
|
this.extrudedHeight
|
||||||
this._EventBinding = new EventBinding()
|
this._EventBinding = new EventBinding()
|
||||||
this.Dialog = _Dialog
|
this.Dialog = _Dialog
|
||||||
@ -71,6 +67,9 @@ class StandText extends Base {
|
|||||||
StandText.create(this)
|
StandText.create(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return
|
||||||
|
}
|
||||||
get text() {
|
get text() {
|
||||||
return this.options.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) {
|
static async create(that) {
|
||||||
|
|
||||||
@ -397,15 +388,13 @@ class StandText extends Base {
|
|||||||
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
||||||
},
|
},
|
||||||
secondaryEditCallBack: () => {
|
secondaryEditCallBack: () => {
|
||||||
StandText.nodeEdit(this)
|
this.nodeEdit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' stand-text'
|
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' stand-text'
|
||||||
let contentElm = document.createElement('div');
|
let contentElm = document.createElement('div');
|
||||||
contentElm.innerHTML = html(this)
|
contentElm.innerHTML = html(this)
|
||||||
this._DialogObject.contentAppChild(contentElm)
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
this.attributeType = this.options.attributeType
|
|
||||||
this.attributeCamera = this.options.attribute.camera
|
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
// this.attributeLink = this.options.attribute.link.content
|
// this.attributeLink = this.options.attribute.link.content
|
||||||
// this.cameraSelect()
|
// this.cameraSelect()
|
||||||
@ -538,23 +527,24 @@ class StandText extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static nodeEdit(that, cb = () => { }) {
|
nodeEdit(cb = () => { }) {
|
||||||
if (YJ.Measure.GetMeasureStatus()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
cb('上一次测量未结束')
|
cb('上一次测量未结束')
|
||||||
} else {
|
} else {
|
||||||
YJ.Measure.SetMeasureStatus(true)
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
this._nodeEditCallback = cb
|
||||||
that.event = new MouseEvent(that.sdk)
|
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||||
that.nodePoints = []
|
this.event = new MouseEvent(this.sdk)
|
||||||
|
this.nodePoints = []
|
||||||
let selectPoint
|
let selectPoint
|
||||||
let originalPosition
|
let originalPosition
|
||||||
|
|
||||||
let positions = that.options.positions
|
let positions = this.options.positions
|
||||||
let fromDegreesArray = []
|
let fromDegreesArray = []
|
||||||
let minimumHeights = []
|
let minimumHeights = []
|
||||||
let maximumHeights = []
|
let maximumHeights = []
|
||||||
let width = that.computeDistance2(positions)
|
let width = this.computeDistance2(positions)
|
||||||
let extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
let extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||||
for (let i = 0; i < positions.length; i++) {
|
for (let i = 0; i < positions.length; i++) {
|
||||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
minimumHeights.push(positions[i].alt)
|
minimumHeights.push(positions[i].alt)
|
||||||
@ -565,55 +555,55 @@ class StandText extends Base {
|
|||||||
let leftEvent = (movement, cartesian) => {
|
let leftEvent = (movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
isAdd = true
|
isAdd = true
|
||||||
let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity])
|
let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity])
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
||||||
originalPosition = that.options.positions[selectPoint.index]
|
originalPosition = this.options.positions[selectPoint.index]
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||||
that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index])
|
this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index])
|
||||||
|
|
||||||
let positions = that.options.positions
|
let positions = this.options.positions
|
||||||
fromDegreesArray = []
|
fromDegreesArray = []
|
||||||
minimumHeights = []
|
minimumHeights = []
|
||||||
maximumHeights = []
|
maximumHeights = []
|
||||||
width = that.computeDistance2(positions)
|
width = this.computeDistance2(positions)
|
||||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||||
for (let i = 0; i < positions.length; i++) {
|
for (let i = 0; i < positions.length; i++) {
|
||||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
minimumHeights.push(positions[i].alt)
|
minimumHeights.push(positions[i].alt)
|
||||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||||
}
|
}
|
||||||
that.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.position.x,
|
movement.position.x,
|
||||||
movement.position.y
|
movement.position.y
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
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') {
|
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||||
selectPoint = pick.id
|
selectPoint = pick.id
|
||||||
that.nodePoints.splice(pick.id.index, 1)
|
this.nodePoints.splice(pick.id.index, 1)
|
||||||
that.sdk.viewer.entities.remove(pick.id)
|
this.sdk.viewer.entities.remove(pick.id)
|
||||||
that.tip.set_text('左键开始,右键结束,CTRL+右键撤销')
|
this.tip.set_text('左键开始,右键结束,CTRL+右键撤销')
|
||||||
originalPosition = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
originalPosition = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
that.entity.wall.positions = new Cesium.CallbackProperty(function () {
|
this.entity.wall.positions = new Cesium.CallbackProperty(function () {
|
||||||
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
}, false)
|
}, false)
|
||||||
that.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () {
|
this.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () {
|
||||||
return maximumHeights
|
return maximumHeights
|
||||||
}, false)
|
}, false)
|
||||||
that.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () {
|
this.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () {
|
||||||
return minimumHeights
|
return minimumHeights
|
||||||
}, false)
|
}, false)
|
||||||
}
|
}
|
||||||
@ -621,69 +611,69 @@ class StandText extends Base {
|
|||||||
}
|
}
|
||||||
let rightEvent = (movement, cartesian) => {
|
let rightEvent = (movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
that.options.positions[selectPoint.index] = originalPosition
|
this.options.positions[selectPoint.index] = originalPosition
|
||||||
if(isAdd) {
|
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 = []
|
fromDegreesArray = []
|
||||||
minimumHeights = []
|
minimumHeights = []
|
||||||
maximumHeights = []
|
maximumHeights = []
|
||||||
width = that.computeDistance2(positions)
|
width = this.computeDistance2(positions)
|
||||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||||
for (let i = 0; i < positions.length; i++) {
|
for (let i = 0; i < positions.length; i++) {
|
||||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
minimumHeights.push(positions[i].alt)
|
minimumHeights.push(positions[i].alt)
|
||||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
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++) {
|
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||||
}
|
}
|
||||||
that.nodePoints = []
|
this.nodePoints = []
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
that.event.destroy()
|
this.event.destroy()
|
||||||
that.tip.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) {
|
if (selectPoint) {
|
||||||
let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity])
|
let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity])
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer)
|
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
||||||
let positions = that.options.positions
|
let positions = this.options.positions
|
||||||
fromDegreesArray = []
|
fromDegreesArray = []
|
||||||
minimumHeights = []
|
minimumHeights = []
|
||||||
maximumHeights = []
|
maximumHeights = []
|
||||||
width = that.computeDistance2(positions)
|
width = this.computeDistance2(positions)
|
||||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||||
for (let i = 0; i < positions.length; i++) {
|
for (let i = 0; i < positions.length; i++) {
|
||||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
minimumHeights.push(positions[i].alt)
|
minimumHeights.push(positions[i].alt)
|
||||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.endPosition.x,
|
movement.endPosition.x,
|
||||||
movement.endPosition.y
|
movement.endPosition.y
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
this.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
that.options.positions.pop()
|
this.options.positions.pop()
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1])
|
this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1])
|
||||||
that.nodePoints.pop()
|
this.nodePoints.pop()
|
||||||
if (selectPoint.index === that.options.positions.length) {
|
if (selectPoint.index === this.options.positions.length) {
|
||||||
if (that.nodePoints[selectPoint.index - 1]) {
|
if (this.nodePoints[selectPoint.index - 1]) {
|
||||||
selectPoint = that.nodePoints[selectPoint.index - 1]
|
selectPoint = this.nodePoints[selectPoint.index - 1]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selectPoint.index = 0
|
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 startTime = new Date()
|
||||||
let pos = {
|
let pos = {
|
||||||
position: {
|
position: {
|
||||||
@ -700,7 +690,7 @@ class StandText extends Base {
|
|||||||
y: (movement.position1.y + movement.position2.y) / 2
|
y: (movement.position1.y + movement.position2.y) / 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.event.gesture_pinck_end(() => {
|
this.event.gesture_pinck_end(() => {
|
||||||
let endTime = new Date()
|
let endTime = new Date()
|
||||||
if (endTime - startTime >= 500) {
|
if (endTime - startTime >= 500) {
|
||||||
// 长按取消
|
// 长按取消
|
||||||
@ -712,20 +702,20 @@ class StandText extends Base {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < that.options.positions.length; i++) {
|
for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
let entity = that.sdk.viewer.entities.add({
|
let entity = this.sdk.viewer.entities.add({
|
||||||
name: 'node-secondary-edit-point',
|
name: 'node-secondary-edit-point',
|
||||||
index: i,
|
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: {
|
billboard: {
|
||||||
image: that.getSourceRootPath() + '/img/point.png',
|
image: this.getSourceRootPath() + '/img/point.png',
|
||||||
width: 15,
|
width: 15,
|
||||||
height: 15,
|
height: 15,
|
||||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
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'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../Global/global'
|
||||||
|
|
||||||
class Base extends Tools {
|
class Base extends Tools {
|
||||||
#_showView
|
|
||||||
#_isShowView
|
|
||||||
constructor(sdk, options = {}) {
|
constructor(sdk, options = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
if (!sdk || !sdk.viewer) {
|
if (!sdk || !sdk.viewer) {
|
||||||
@ -32,8 +30,13 @@ class Base extends Tools {
|
|||||||
this.rightClickCallBack = null
|
this.rightClickCallBack = null
|
||||||
this.picking = true
|
this.picking = true
|
||||||
this.options.host = this.options.host || getHost()
|
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.setDefaultValue()
|
||||||
|
this._showView
|
||||||
|
|
||||||
// this.sdk.addIncetance(this.options.id, this)
|
// this.sdk.addIncetance(this.options.id, this)
|
||||||
}
|
}
|
||||||
@ -60,7 +63,7 @@ class Base extends Tools {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
get showView() {
|
get showView() {
|
||||||
return this.#_showView
|
return this._showView
|
||||||
}
|
}
|
||||||
|
|
||||||
set showView(v) {
|
set showView(v) {
|
||||||
@ -68,28 +71,28 @@ class Base extends Tools {
|
|||||||
|
|
||||||
let sdk2D = get2DSdk().sdkD
|
let sdk2D = get2DSdk().sdkD
|
||||||
if (!sdk2D) {
|
if (!sdk2D) {
|
||||||
this.#_showView = v
|
this._showView = v
|
||||||
if (this.entity) {
|
if (this.entity) {
|
||||||
this.entity._showView = v
|
this.entity._showView = v
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.sdk === sdk2D) {
|
if (this.sdk === sdk2D) {
|
||||||
this.#_showView = 0
|
this._showView = 0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.#_showView && !this.show) {
|
if (!this._showView && !this.show) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.sdk === sdk2D) {
|
if (this.sdk === sdk2D) {
|
||||||
this.#_showView = 0
|
this._showView = 0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (v != 2 && v != 3) {
|
if (v != 2 && v != 3) {
|
||||||
this.#_showView = 0
|
this._showView = 0
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.#_showView = v
|
this._showView = v
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isShowView = true
|
this.isShowView = true
|
||||||
@ -98,7 +101,7 @@ class Base extends Tools {
|
|||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!this.#_showView) {
|
if (!this._showView) {
|
||||||
this.show = true
|
this.show = true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -502,7 +505,10 @@ class Base extends Tools {
|
|||||||
|
|
||||||
// 重置视角
|
// 重置视角
|
||||||
resetCustomView() {
|
resetCustomView() {
|
||||||
this.options.customView = undefined
|
this.options.customView = {
|
||||||
|
relativePosition: undefined,
|
||||||
|
orientation: undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class EventBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on(that, elements) {
|
on(that, elements) {
|
||||||
|
return
|
||||||
this.element = {}
|
this.element = {}
|
||||||
for (let i = 0; i < elements.length; i++) {
|
for (let i = 0; i < elements.length; i++) {
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
|
@ -127,9 +127,9 @@ class Tools {
|
|||||||
var alt = cartographic.height < 0 ? 0 : cartographic.height
|
var alt = cartographic.height < 0 ? 0 : cartographic.height
|
||||||
// var alt = cartographic.height
|
// var alt = cartographic.height
|
||||||
return {
|
return {
|
||||||
lng: lng,
|
lng: Number(lng.toFixed(8)),
|
||||||
lat: lat,
|
lat: Number(lat.toFixed(8)),
|
||||||
alt: alt,
|
alt: Number(alt.toFixed(2)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,13 +141,14 @@ class Tools {
|
|||||||
* @param [fractionDigits=2] 保留小数点位数
|
* @param [fractionDigits=2] 保留小数点位数
|
||||||
* @param [ground=true] 是否贴地
|
* @param [ground=true] 是否贴地
|
||||||
* */
|
* */
|
||||||
async computeDistance(positions = [], fractionDigits = 2, type = '空间长度') {
|
async computeDistance(positions = [], fractionDigits = 2, type = 0) {
|
||||||
if (positions.length < 2) {
|
if (positions.length < 2) {
|
||||||
return 0
|
return 0
|
||||||
} else {
|
} else {
|
||||||
let length = 0
|
let length = 0
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case '空间长度':
|
case '0':
|
||||||
|
case 0:
|
||||||
for (let i = 0; i < positions.length - 1; i++) {
|
for (let i = 0; i < positions.length - 1; i++) {
|
||||||
const position1 = Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, positions[i].alt);
|
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);
|
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
|
length = length + distance
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case '投影长度':
|
case '1':
|
||||||
|
case 1:
|
||||||
for (let i = 0; i < positions.length - 1; i++) {
|
for (let i = 0; i < positions.length - 1; i++) {
|
||||||
const position1 = Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, 0);
|
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);
|
const position2 = Cesium.Cartesian3.fromDegrees(positions[i + 1].lng, positions[i + 1].lat, 0);
|
||||||
@ -163,7 +165,8 @@ class Tools {
|
|||||||
length = length + distance
|
length = length + distance
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case '地表长度':
|
case '2':
|
||||||
|
case 2:
|
||||||
let meters
|
let meters
|
||||||
let lineString2 = []
|
let lineString2 = []
|
||||||
positions.forEach((item) => {
|
positions.forEach((item) => {
|
||||||
@ -1243,14 +1246,28 @@ class Tools {
|
|||||||
* */
|
* */
|
||||||
deepCopyObj(obj) {
|
deepCopyObj(obj) {
|
||||||
let newobj = null;
|
let newobj = null;
|
||||||
//判断是否需要继续进行递归
|
// 处理数组 - 使用原生Array构造函数创建新数组
|
||||||
if (typeof (obj) == 'object' && obj !== null) {
|
if (Array.isArray(obj)) {
|
||||||
newobj = obj instanceof Array ? [] : {}; //进行下一层递归克隆
|
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) {
|
for (let i in obj) {
|
||||||
if (i != 'earth' && i != 'Dialog')
|
// 排除指定属性和方法属性
|
||||||
newobj[i] = this.deepCopyObj(obj[i])
|
if (i !== 'earth' && i !== 'Dialog' && typeof obj[i] !== 'function') {
|
||||||
} //如果不是对象直接赋值
|
newobj[i] = this.deepCopyObj(obj[i]);
|
||||||
} else newobj = obj;
|
}
|
||||||
|
}
|
||||||
|
return newobj;
|
||||||
|
}
|
||||||
|
else newobj = obj;
|
||||||
return newobj;
|
return newobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ import YJColorPicker from "../Obj/Element/yj-color-picker";
|
|||||||
|
|
||||||
class YJEarth {
|
class YJEarth {
|
||||||
#_requestAnimationFrameEventId = undefined
|
#_requestAnimationFrameEventId = undefined
|
||||||
|
#_BillboardCollection
|
||||||
|
#_LabelCollection
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param div_id {string} 地球所在的dom id
|
* @param div_id {string} 地球所在的dom id
|
||||||
@ -272,6 +274,34 @@ class YJEarth {
|
|||||||
this.viewer.scene.fxaa = true
|
this.viewer.scene.fxaa = true
|
||||||
this.viewer.scene.postProcessStages.fxaa.enabled = true
|
this.viewer.scene.postProcessStages.fxaa.enabled = true
|
||||||
this.viewer.scene.screenSpaceCameraController.enableCollisionDetection = true //true 禁止 false 允许
|
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)
|
createCluster(this.viewer)
|
||||||
keyboardMapRoamingInit(this.viewer)
|
keyboardMapRoamingInit(this.viewer)
|
||||||
let a = Cesium.viewerCesiumNavigationMixin(this.viewer, {
|
let a = Cesium.viewerCesiumNavigationMixin(this.viewer, {
|
||||||
@ -522,6 +552,13 @@ class YJEarth {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get collection() {
|
||||||
|
return {
|
||||||
|
billboard: this.#_BillboardCollection,
|
||||||
|
label: this.#_LabelCollection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
cancelAnimationFrame(this.#_requestAnimationFrameEventId)
|
cancelAnimationFrame(this.#_requestAnimationFrameEventId)
|
||||||
for (let [id, obj] of this.entityMap) {
|
for (let [id, obj] of this.entityMap) {
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
color: var(--color-sdk-auxiliary-public);
|
color: var(--color-sdk-auxiliary-public);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
z-index: 999999;
|
z-index: 99;
|
||||||
background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6);
|
background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6);
|
||||||
border: 1.5px solid;
|
border: 1.5px solid;
|
||||||
border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1;
|
border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1;
|
||||||
@ -76,8 +76,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.YJ-custom-base-dialog * {
|
.YJ-custom-base-dialog * {
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +169,7 @@
|
|||||||
position: relative;
|
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;
|
border-color: rgba(var(--color-sdk-base-rgb), 1) !important;
|
||||||
cursor: pointer;
|
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