合并
This commit is contained in:
@ -28,7 +28,6 @@ class PincerArrowObject extends Base {
|
||||
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||
* @param options.height {number} 高度
|
||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||
* @param options.areaUnit='平方米' {string} 面积单位
|
||||
* @param options.line {object} 边框
|
||||
* @param options.line.width=2 {string} 边框宽
|
||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||
@ -83,7 +82,6 @@ class PincerArrowObject extends Base {
|
||||
this.options.line = options.line || {}
|
||||
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
|
||||
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||
this.options.height = options.height
|
||||
this.options.loop = options.loop || false
|
||||
this.options.spreadState = options.spreadState || false
|
||||
@ -113,13 +111,10 @@ class PincerArrowObject extends Base {
|
||||
this.options.attribute = options.attribute || {}
|
||||
this.options.attribute.link = this.options.attribute.link || {}
|
||||
this.options.attribute.link.content = this.options.attribute.link.content || []
|
||||
this.options.attribute.camera = this.options.attribute.camera || {}
|
||||
this.options.attribute.camera.content = this.options.attribute.camera.content || []
|
||||
this.options.attribute.vr = this.options.attribute.vr || {}
|
||||
this.options.attribute.vr.content = this.options.attribute.vr.content || []
|
||||
this.options.attribute.goods = this.options.attribute.goods || {}
|
||||
this.options.attribute.goods.content = this.options.attribute.goods.content || []
|
||||
this.options.attributeType = options.attributeType || 'richText'
|
||||
|
||||
delete this.options.attribute.camera
|
||||
delete this.options.attribute.vr
|
||||
delete this.options.attribute.goods
|
||||
|
||||
if (!this.options.positions || this.options.positions.length < 5) {
|
||||
this._error = '双箭头最少需要五个坐标!'
|
||||
@ -208,7 +203,7 @@ class PincerArrowObject extends Base {
|
||||
return
|
||||
}
|
||||
let heightModeName = ''
|
||||
PincerArrowObject.closeNodeEdit(this)
|
||||
this.closeNodeEdit()
|
||||
let ground = false
|
||||
let disabled = false
|
||||
this.renewPositions()
|
||||
@ -332,45 +327,6 @@ class PincerArrowObject extends Base {
|
||||
})
|
||||
}
|
||||
|
||||
get area() {
|
||||
return this.options.area
|
||||
}
|
||||
|
||||
set area(v) {
|
||||
this.options.area = v
|
||||
this._elms.area && this._elms.area.forEach((item) => {
|
||||
item.value = v
|
||||
})
|
||||
}
|
||||
|
||||
get areaUnit() {
|
||||
return this.options['area-unit']
|
||||
}
|
||||
set areaUnit(v) {
|
||||
this.options['area-unit'] = v
|
||||
this._elms.areaUnit && this._elms.areaUnit.forEach((item) => {
|
||||
item.value = v
|
||||
})
|
||||
if (this.options.areaByMeter) {
|
||||
switch (v) {
|
||||
case '平方米':
|
||||
this.area = this.options.areaByMeter
|
||||
break;
|
||||
case '平方千米':
|
||||
this.area = Number((this.options.areaByMeter / 1000000).toFixed(8))
|
||||
break;
|
||||
case '亩':
|
||||
this.area = Number((this.options.areaByMeter / 666.6666667).toFixed(4))
|
||||
break;
|
||||
case '公顷':
|
||||
this.area = Number((this.options.areaByMeter / 10000).toFixed(6))
|
||||
break;
|
||||
default:
|
||||
this.area = this.options.areaByMeter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get labelShow() {
|
||||
return this.options.label.show
|
||||
}
|
||||
@ -582,320 +538,6 @@ class PincerArrowObject extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
get attributeType() {
|
||||
return this.options.attributeType
|
||||
}
|
||||
|
||||
set attributeType(v) {
|
||||
this.options.attributeType = v
|
||||
this._elms.attributeType && this._elms.attributeType.forEach((item) => {
|
||||
item.value = v
|
||||
})
|
||||
let attributeContent = this._DialogObject._element.content.getElementsByClassName('attribute-content')
|
||||
for (let i = 0; i < attributeContent.length; i++) {
|
||||
if (attributeContent[i].className.indexOf('attribute-content-' + v) > -1) {
|
||||
attributeContent[i].style.display = 'block';
|
||||
}
|
||||
else {
|
||||
attributeContent[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get attributeLink() {
|
||||
return this.options.attribute.link.content
|
||||
}
|
||||
|
||||
set attributeLink(v) {
|
||||
this.options.attribute.link.content = v
|
||||
if (!this._DialogObject || !this._DialogObject._element || !this._DialogObject._element.content || this._DialogObject._element.content.getElementsByClassName('attribute-content-link').length == 0) {
|
||||
return
|
||||
}
|
||||
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-link')[1].getElementsByClassName('table')[0]
|
||||
let tableContent = table.getElementsByClassName('table-body')[0]
|
||||
tableContent.innerHTML = ''
|
||||
if (this.options.attribute.link.content.length > 0) {
|
||||
table.getElementsByClassName('table-empty')[0].style.display = 'none'
|
||||
}
|
||||
else {
|
||||
table.getElementsByClassName('table-empty')[0].style.display = 'flex'
|
||||
}
|
||||
for (let i = 0; i < this.options.attribute.link.content.length; i++) {
|
||||
let tr = `
|
||||
<div class="tr">
|
||||
<div class="td">` + this.options.attribute.link.content[i].name + `</div>
|
||||
<div class="td">` + this.options.attribute.link.content[i].url + `</div>
|
||||
<div class="td">
|
||||
<button @click="linkEdit">编辑</button>
|
||||
<button @click="linkDelete">删除</button>
|
||||
</div>
|
||||
</div>`
|
||||
let trElm = document.createRange().createContextualFragment(tr)
|
||||
tableContent.appendChild(trElm)
|
||||
}
|
||||
let item = tableContent.getElementsByClassName('tr')
|
||||
let fun = {
|
||||
linkEdit: async (index) => {
|
||||
this.attributeLink = await this.options.attribute.link.content
|
||||
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-link')[1].getElementsByClassName('table')[0]
|
||||
let tableContent = table.getElementsByClassName('table-body')[0]
|
||||
let item = tableContent.getElementsByClassName('tr')
|
||||
for (let i = 0; i < item.length; i++) {
|
||||
if (index === i) {
|
||||
let height = item[i].offsetHeight
|
||||
let html = `
|
||||
<div class="td">
|
||||
<input class="input" type="text">
|
||||
</div>
|
||||
<div class="td">
|
||||
<textarea class="input link-edit" type="text"></textarea>
|
||||
</div>
|
||||
<div class="td">
|
||||
<button @click="confirmEdit">确认</button>
|
||||
<button @click="cancelEdit">取消</button>
|
||||
</div>`
|
||||
item[i].innerHTML = html
|
||||
let textareaElm = item[i].getElementsByClassName('link-edit')[0]
|
||||
textareaElm.style.height = (height - 10) + 'px'
|
||||
let td = item[i].getElementsByClassName('td')
|
||||
td[0].getElementsByClassName('input')[0].value = this.options.attribute.link.content[index].name
|
||||
td[1].getElementsByClassName('input')[0].value = this.options.attribute.link.content[index].url
|
||||
let btn = item[i].getElementsByTagName('button')
|
||||
for (let n = 0; n < btn.length; n++) {
|
||||
if (!btn[n] || !btn[n].attributes) {
|
||||
continue
|
||||
}
|
||||
for (let m of btn[n].attributes) {
|
||||
if (m.name === '@click') {
|
||||
btn[n].addEventListener('click', (e) => {
|
||||
if (typeof (fun[m.value]) === 'function') {
|
||||
fun[m.value]({ name: td[0].getElementsByClassName('input')[0].value, url: td[1].getElementsByClassName('input')[0].value }, i)
|
||||
}
|
||||
});
|
||||
btn[n].attributes.removeNamedItem(m.name)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
linkDelete: (i) => {
|
||||
this.options.attribute.link.content.splice(i, 1)
|
||||
this.attributeLink = this.options.attribute.link.content
|
||||
},
|
||||
|
||||
confirmEdit: (value, i) => {
|
||||
let name = value.name && value.name.replace(/\s/g, "")
|
||||
let url = value.url && value.url.replace(/\s/g, "")
|
||||
if (name && url) {
|
||||
this.options.attribute.link.content[i] = value
|
||||
}
|
||||
else {
|
||||
window.ELEMENT && window.ELEMENT.Message({
|
||||
message: '名称或链接不能为空!',
|
||||
type: 'warning',
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
this.attributeLink = this.options.attribute.link.content
|
||||
},
|
||||
cancelEdit: () => {
|
||||
this.attributeLink = this.options.attribute.link.content
|
||||
},
|
||||
fileSelect: (value, i) => {
|
||||
let fileElm = item[i].getElementsByClassName('file-select')[0]
|
||||
fileElm.click()
|
||||
fileElm.removeEventListener('change', fileSelect)
|
||||
fileElm.addEventListener('change', fileSelect)
|
||||
}
|
||||
}
|
||||
let fileSelect = (event) => {
|
||||
if (event.target.value) {
|
||||
let td = item[event.target.getAttribute('index')].getElementsByClassName('td')
|
||||
td[1].getElementsByClassName('input')[0].value = event.target.value
|
||||
event.target.value = null
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < item.length; i++) {
|
||||
let btn = item[i].getElementsByTagName('button')
|
||||
for (let n = 0; n < btn.length; n++) {
|
||||
if (!btn[n] || !btn[n].attributes) {
|
||||
continue
|
||||
}
|
||||
for (let m of btn[n].attributes) {
|
||||
if (m.name === '@click') {
|
||||
btn[n].addEventListener('click', (e) => {
|
||||
if (typeof (fun[m.value]) === 'function') {
|
||||
fun[m.value](i)
|
||||
}
|
||||
});
|
||||
btn[n].attributes.removeNamedItem(m.name)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
get attributeCamera() {
|
||||
return this.options.attribute.camera.content
|
||||
}
|
||||
|
||||
set attributeCamera(v) {
|
||||
this.options.attribute.camera.content = v
|
||||
}
|
||||
|
||||
get attributeVr() {
|
||||
return this.options.attribute.vr.content
|
||||
}
|
||||
|
||||
set attributeVr(v) {
|
||||
this.options.attribute.vr.content = v
|
||||
if (!this._DialogObject || !this._DialogObject._element || !this._DialogObject._element.content || this._DialogObject._element.content.getElementsByClassName('attribute-content-vr').length == 0) {
|
||||
return
|
||||
}
|
||||
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-vr')[1].getElementsByClassName('table')[0]
|
||||
let tableContent = table.getElementsByClassName('table-body')[0]
|
||||
tableContent.innerHTML = ''
|
||||
if (this.options.attribute.vr.content.length > 0) {
|
||||
table.getElementsByClassName('table-empty')[0].style.display = 'none'
|
||||
}
|
||||
else {
|
||||
table.getElementsByClassName('table-empty')[0].style.display = 'flex'
|
||||
}
|
||||
for (let i = 0; i < this.options.attribute.vr.content.length; i++) {
|
||||
let tr = `
|
||||
<div class="tr">
|
||||
<div class="td">` + this.options.attribute.vr.content[i].name + `</div>
|
||||
<div class="td">` + this.options.attribute.vr.content[i].url + `</div>
|
||||
<div class="td">
|
||||
<button @click="vrEdit">编辑</button>
|
||||
<button @click="vrDelete">删除</button>
|
||||
</div>
|
||||
</div>`
|
||||
let trElm = document.createRange().createContextualFragment(tr)
|
||||
tableContent.appendChild(trElm)
|
||||
}
|
||||
let item = tableContent.getElementsByClassName('tr')
|
||||
let fun = {
|
||||
vrEdit: async (index) => {
|
||||
this.attributeVr = await this.options.attribute.vr.content
|
||||
let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-vr')[1].getElementsByClassName('table')[0]
|
||||
let tableContent = table.getElementsByClassName('table-body')[0]
|
||||
let item = tableContent.getElementsByClassName('tr')
|
||||
for (let i = 0; i < item.length; i++) {
|
||||
if (index === i) {
|
||||
let height = item[i].offsetHeight
|
||||
let html = `
|
||||
<div class="td">
|
||||
<input class="input" type="text">
|
||||
</div>
|
||||
<div class="td">
|
||||
<textarea class="input link-edit" type="text"></textarea>
|
||||
</div>
|
||||
<div class="td">
|
||||
<button @click="confirmEdit">确认</button>
|
||||
<button @click="cancelEdit">取消</button>
|
||||
</div>`
|
||||
item[i].innerHTML = html
|
||||
let textareaElm = item[i].getElementsByClassName('link-edit')[0]
|
||||
textareaElm.style.height = (height - 10) + 'px'
|
||||
let td = item[i].getElementsByClassName('td')
|
||||
td[0].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].name
|
||||
td[1].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].url
|
||||
let btn = item[i].getElementsByTagName('button')
|
||||
for (let n = 0; n < btn.length; n++) {
|
||||
if (!btn[n] || !btn[n].attributes) {
|
||||
continue
|
||||
}
|
||||
for (let m of btn[n].attributes) {
|
||||
if (m.name === '@click') {
|
||||
btn[n].addEventListener('click', (e) => {
|
||||
if (typeof (fun[m.value]) === 'function') {
|
||||
fun[m.value]({ name: td[0].getElementsByClassName('input')[0].value, url: td[1].getElementsByClassName('input')[0].value }, i)
|
||||
}
|
||||
});
|
||||
btn[n].attributes.removeNamedItem(m.name)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
vrDelete: (i) => {
|
||||
this.options.attribute.vr.content.splice(i, 1)
|
||||
this.attributeVr = this.options.attribute.vr.content
|
||||
},
|
||||
|
||||
confirmEdit: (value, i) => {
|
||||
let name = value.name && value.name.replace(/\s/g, "")
|
||||
let url = value.url && value.url.replace(/\s/g, "")
|
||||
if (name && url) {
|
||||
this.options.attribute.vr.content[i] = value
|
||||
}
|
||||
else {
|
||||
window.ELEMENT && window.ELEMENT.Message({
|
||||
message: '名称或链接不能为空!',
|
||||
type: 'warning',
|
||||
duration: 1500
|
||||
});
|
||||
}
|
||||
this.attributeVr = this.options.attribute.vr.content
|
||||
},
|
||||
cancelEdit: () => {
|
||||
this.attributeVr = this.options.attribute.vr.content
|
||||
},
|
||||
fileSelect: (value, i) => {
|
||||
let fileElm = item[i].getElementsByClassName('file-select')[0]
|
||||
fileElm.click()
|
||||
fileElm.removeEventListener('change', fileSelect)
|
||||
fileElm.addEventListener('change', fileSelect)
|
||||
}
|
||||
}
|
||||
let fileSelect = (event) => {
|
||||
if (event.target.value) {
|
||||
let td = item[event.target.getAttribute('index')].getElementsByClassName('td')
|
||||
td[1].getElementsByClassName('input')[0].value = event.target.value
|
||||
event.target.value = null
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < item.length; i++) {
|
||||
let btn = item[i].getElementsByTagName('button')
|
||||
for (let n = 0; n < btn.length; n++) {
|
||||
if (!btn[n] || !btn[n].attributes) {
|
||||
continue
|
||||
}
|
||||
for (let m of btn[n].attributes) {
|
||||
if (m.name === '@click') {
|
||||
btn[n].addEventListener('click', (e) => {
|
||||
if (typeof (fun[m.value]) === 'function') {
|
||||
fun[m.value](i)
|
||||
}
|
||||
});
|
||||
btn[n].attributes.removeNamedItem(m.name)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get attributeGoods() {
|
||||
return this.options.attribute.goods.content
|
||||
}
|
||||
|
||||
set attributeGoods(v) {
|
||||
this.options.attribute.goods.content = v
|
||||
}
|
||||
|
||||
static create(that) {
|
||||
let positions = that.options.positions
|
||||
let fromDegreesArray = []
|
||||
@ -939,9 +581,10 @@ class PincerArrowObject extends Base {
|
||||
break
|
||||
}
|
||||
|
||||
if (!that.options.label.position) {
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
}
|
||||
// if (!that.options.label.position) {
|
||||
// that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
// }
|
||||
that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height }
|
||||
|
||||
let fromDegreesArray2 = []
|
||||
for (let i = 0; i < points[0].length; i++) {
|
||||
@ -959,7 +602,7 @@ class PincerArrowObject extends Base {
|
||||
color: that.options.color
|
||||
})
|
||||
}
|
||||
that.options.label.ground = ground
|
||||
// that.options.label.ground = ground
|
||||
|
||||
that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2)
|
||||
|
||||
@ -987,23 +630,8 @@ class PincerArrowObject extends Base {
|
||||
for (let i = 0; i < positionsA.length; i++) {
|
||||
pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer))
|
||||
}
|
||||
that.options.areaByMeter = that.computeArea(pos84);
|
||||
switch (that.options['area-unit']) {
|
||||
case '平方米':
|
||||
that.options.area = that.options.areaByMeter
|
||||
break;
|
||||
case '平方千米':
|
||||
that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8))
|
||||
break;
|
||||
case '亩':
|
||||
that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4))
|
||||
break;
|
||||
case '公顷':
|
||||
that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
||||
break;
|
||||
default:
|
||||
that.options.area = that.options.areaByMeter
|
||||
}
|
||||
that.areaByMeter = that.computeArea(pos84);
|
||||
that.areaChangeCallBack && that.areaChangeCallBack()
|
||||
syncData(that.sdk, that.options.id)
|
||||
if (that.options.show) {
|
||||
|
||||
@ -1030,12 +658,13 @@ class PincerArrowObject extends Base {
|
||||
scaleByDistance: that.options.label.scaleByDistance,
|
||||
near: that.options.label.near,
|
||||
far: that.options.label.far,
|
||||
ground: that.options.label.ground,
|
||||
// ground: that.options.label.ground,
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑框
|
||||
async edit(state) {
|
||||
return
|
||||
if (this._error) {
|
||||
return
|
||||
}
|
||||
@ -1534,8 +1163,6 @@ class PincerArrowObject extends Base {
|
||||
this.color = this.originalOptions.color
|
||||
this.lineColor = this.originalOptions.line.color
|
||||
this.lineWidth = this.originalOptions.line.width
|
||||
this.area = this.originalOptions.area
|
||||
this.areaUnit = this.originalOptions['area-unit']
|
||||
this.labelShow = this.originalOptions.label.show
|
||||
this.labelColor = this.originalOptions.label.color
|
||||
this.labelFontSize = this.originalOptions.label.fontSize
|
||||
@ -1548,12 +1175,7 @@ class PincerArrowObject extends Base {
|
||||
this.labelLineColor = this.originalOptions.label.lineColor
|
||||
this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0]
|
||||
this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1]
|
||||
this.attributeLink = this.options.attribute.link.content
|
||||
this.attributeVr = this.options.attribute.vr.content
|
||||
this.attributeCamera = this.options.attribute.camera.content
|
||||
this.attributeGoods = this.options.attribute.goods.content
|
||||
this.cameraSelect && this.cameraSelect()
|
||||
this.goodsSelect && this.goodsSelect()
|
||||
|
||||
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
if (this._elms.lng && this._elms.lng[i]) {
|
||||
@ -1607,51 +1229,6 @@ class PincerArrowObject extends Base {
|
||||
await syncData(this.sdk, this.options.id)
|
||||
}
|
||||
|
||||
_addLink() {
|
||||
// document.getElementsByClassName
|
||||
if (this._DialogObject._element.content.getElementsByClassName('link_add')[0].value) {
|
||||
this.options.attribute.link.content.push({
|
||||
name: '链接',
|
||||
url: this._DialogObject._element.content.getElementsByClassName('link_add')[0].value
|
||||
})
|
||||
this._DialogObject._element.content.getElementsByClassName('link_add')[0].value = ''
|
||||
this.attributeLink = this.options.attribute.link.content
|
||||
}
|
||||
else {
|
||||
this.Dialog.clickAddLink && this.Dialog.clickAddLink()
|
||||
}
|
||||
}
|
||||
|
||||
addAttributeLink(link) {
|
||||
this.options.attribute.link.content.push({
|
||||
name: '链接',
|
||||
url: link
|
||||
})
|
||||
this.attributeLink = this.options.attribute.link.content
|
||||
}
|
||||
|
||||
_addRr() {
|
||||
if (this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value) {
|
||||
this.options.attribute.vr.content.push({
|
||||
name: '全景图' ,
|
||||
url: this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value
|
||||
})
|
||||
this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value = ''
|
||||
this.attributeVr = this.options.attribute.vr.content
|
||||
}
|
||||
else {
|
||||
this.Dialog.clickAddVr && this.Dialog.clickAddVr()
|
||||
}
|
||||
}
|
||||
|
||||
addAttributeRr(vr) {
|
||||
this.options.attribute.vr.content.push({
|
||||
name: '全景图' ,
|
||||
url: vr
|
||||
})
|
||||
this.attributeVr = this.options.attribute.vr.content
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞到
|
||||
*/
|
||||
@ -1852,6 +1429,11 @@ class PincerArrowObject extends Base {
|
||||
positions: [...this.positions]
|
||||
}
|
||||
this.positionEditing = false
|
||||
|
||||
if(this._positionEditingCallback) {
|
||||
this._positionEditingCallback()
|
||||
this._positionEditingCallback = null
|
||||
}
|
||||
})
|
||||
this.event.mouse_right((movement, cartesian) => {
|
||||
this.positionEditing = false
|
||||
@ -1954,208 +1536,122 @@ class PincerArrowObject extends Base {
|
||||
get positionEditing() {
|
||||
return this.operate.positionEditing
|
||||
}
|
||||
|
||||
static EventBinding(that, elements) {
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let Event = []
|
||||
let isEvent = false
|
||||
let removeName = []
|
||||
if (!elements[i] || !elements[i].attributes) {
|
||||
continue
|
||||
}
|
||||
for (let m of elements[i].attributes) {
|
||||
switch (m.name) {
|
||||
case '@model': {
|
||||
isEvent = true
|
||||
if (elements[i].type == 'checkbox') {
|
||||
Event.push((e) => { that[m.value] = e.target.checked })
|
||||
elements[i].checked = that[m.value]
|
||||
}
|
||||
else {
|
||||
Event.push((e) => {
|
||||
let value = e.target.value
|
||||
if (e.target.type == 'number') {
|
||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
||||
value = Number(value)
|
||||
if ((e.target.max) && value > Number(e.target.max)) {
|
||||
value = Number(e.target.max)
|
||||
}
|
||||
if ((e.target.min) && value < Number(e.target.min)) {
|
||||
value = Number(e.target.min)
|
||||
}
|
||||
that[m.value] = value
|
||||
}
|
||||
}
|
||||
else {
|
||||
that[m.value] = value
|
||||
}
|
||||
})
|
||||
if (elements[i].nodeName == 'IMG') {
|
||||
elements[i].src = that[m.value]
|
||||
}
|
||||
else {
|
||||
elements[i].value = that[m.value]
|
||||
}
|
||||
}
|
||||
if (that._elms[m.value]) {
|
||||
that._elms[m.value].push(elements[i])
|
||||
}
|
||||
else {
|
||||
that._elms[m.value] = [elements[i]]
|
||||
}
|
||||
removeName.push(m.name)
|
||||
break;
|
||||
}
|
||||
case '@click': {
|
||||
elements[i].addEventListener('click', (e) => {
|
||||
if (typeof (that[m.value]) === 'function') {
|
||||
that[m.value](e)
|
||||
}
|
||||
});
|
||||
removeName.push(m.name)
|
||||
// elements[i].attributes.removeNamedItem(m.name)
|
||||
break;
|
||||
}
|
||||
case '@change': {
|
||||
isEvent = true
|
||||
Event.push((e) => {
|
||||
let value = e.target.value
|
||||
if (e.target.type == 'number' && value != '') {
|
||||
value = Number(value)
|
||||
e.target.value = value
|
||||
}
|
||||
if (typeof (that[m.value]) === 'function') {
|
||||
that[m.value](e, value)
|
||||
}
|
||||
})
|
||||
break;
|
||||
}
|
||||
}
|
||||
// elements[i].attributes[m] = undefined
|
||||
}
|
||||
for (let n = 0; n < removeName.length; n++) {
|
||||
elements[i].attributes.removeNamedItem(removeName[n])
|
||||
}
|
||||
|
||||
if (isEvent) {
|
||||
let ventType = 'input'
|
||||
if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') {
|
||||
ventType = 'change'
|
||||
}
|
||||
if (elements[i].className.indexOf('blur') !== -1) {
|
||||
ventType = 'blur'
|
||||
}
|
||||
elements[i].addEventListener(ventType, (e) => {
|
||||
for (let t = 0; t < Event.length; t++) {
|
||||
Event[t](e)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
openPositionEditing(cd) {
|
||||
this.positionEditing = true
|
||||
this._positionEditingCallback = cd
|
||||
}
|
||||
get areaChangeCallBack() {
|
||||
return this._areaChangeCallBack
|
||||
}
|
||||
|
||||
static nodeEdit(that, cb = () => { }) {
|
||||
that.positionEditing = false
|
||||
set areaChangeCallBack (cd) {
|
||||
this._areaChangeCallBack = cd
|
||||
}
|
||||
|
||||
|
||||
nodeEdit(cb = () => { }) {
|
||||
this.positionEditing = false
|
||||
setTimeout(() => {
|
||||
if (YJ.Measure.GetMeasureStatus()) {
|
||||
cb('上一次测量未结束')
|
||||
} else {
|
||||
that.removeAnimate()
|
||||
this.removeAnimate()
|
||||
let _this = this
|
||||
YJ.Measure.SetMeasureStatus(true)
|
||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
||||
that.event = new MouseEvent(that.sdk)
|
||||
that.nodePoints = []
|
||||
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.nodePoints = []
|
||||
let selectPoint
|
||||
let originalPosition
|
||||
let optionsPositions = [...that.options.positions]
|
||||
let optionsPositions = [...this.options.positions]
|
||||
|
||||
let leftEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
optionsPositions[selectPoint.index] = that.options.positions[selectPoint.index]
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
optionsPositions[selectPoint.index] = this.options.positions[selectPoint.index]
|
||||
let index = selectPoint.index
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let entity = this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: index,
|
||||
position: Cesium.Cartesian3.fromDegrees(optionsPositions[selectPoint.index].lng, optionsPositions[selectPoint.index].lat, optionsPositions[selectPoint.index].alt),
|
||||
billboard: {
|
||||
image: that.getSourceRootPath() + '/img/point.png',
|
||||
image: this.getSourceRootPath() + '/img/point.png',
|
||||
width: 15,
|
||||
height: 15,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||
},
|
||||
})
|
||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
selectPoint = null
|
||||
that.tip.set_text('请选择一个顶点,右键取消')
|
||||
this.tip.set_text('请选择一个顶点,右键取消')
|
||||
}
|
||||
else {
|
||||
var pick = that.sdk.viewer.scene.pick(movement.position);
|
||||
var pick = this.sdk.viewer.scene.pick(movement.position);
|
||||
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||
selectPoint = pick.id
|
||||
originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer)
|
||||
that.nodePoints.splice(pick.id.index, 1)
|
||||
that.sdk.viewer.entities.remove(pick.id)
|
||||
that.tip.set_text('左键确定,右键取消')
|
||||
originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer)
|
||||
this.nodePoints.splice(pick.id.index, 1)
|
||||
this.sdk.viewer.entities.remove(pick.id)
|
||||
this.tip.set_text('左键确定,右键取消')
|
||||
}
|
||||
}
|
||||
that.renewPositions()
|
||||
that.tip.setPosition(
|
||||
this.renewPositions()
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.position.x,
|
||||
movement.position.y
|
||||
)
|
||||
}
|
||||
let rightEvent = () => {
|
||||
that.event.mouse_move(() => { })
|
||||
that.event.mouse_left(() => { })
|
||||
that.event.mouse_right(() => { })
|
||||
that.event.gesture_pinck_start(() => { })
|
||||
this.event.mouse_move(() => { })
|
||||
this.event.mouse_left(() => { })
|
||||
this.event.mouse_right(() => { })
|
||||
this.event.gesture_pinck_start(() => { })
|
||||
if (selectPoint) {
|
||||
optionsPositions[selectPoint.index] = originalPosition
|
||||
if (that._elms.lng && that._elms.lng[selectPoint.index]) {
|
||||
that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
if (this._elms.lng && this._elms.lng[selectPoint.index]) {
|
||||
this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8)
|
||||
}
|
||||
if (that._elms.lat && that._elms.lat[selectPoint.index]) {
|
||||
that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
if (this._elms.lat && this._elms.lat[selectPoint.index]) {
|
||||
this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8)
|
||||
}
|
||||
cb(null, optionsPositions)
|
||||
}
|
||||
that.options.positions = [...optionsPositions]
|
||||
that.heightMode = that.heightMode
|
||||
that.previous = null
|
||||
this.options.positions = [...optionsPositions]
|
||||
this.heightMode = this.heightMode
|
||||
this.previous = null
|
||||
}
|
||||
|
||||
|
||||
that.entity.polyline.clampToGround = true
|
||||
that.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
||||
that.entity.polygon.perPositionHeight = false
|
||||
that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||
return new Cesium.PolygonHierarchy(that.positionsH)
|
||||
this.entity.polyline.clampToGround = true
|
||||
this.entity.polyline.arcType = Cesium.ArcType.GEODESIC
|
||||
this.entity.polygon.perPositionHeight = false
|
||||
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||
return new Cesium.PolygonHierarchy(_this.positionsH)
|
||||
}, false)
|
||||
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
return [...that.positionsH, that.positionsH[0], that.positionsH[1]]
|
||||
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
|
||||
return [..._this.positionsH, _this.positionsH[0], _this.positionsH[1]]
|
||||
}, false)
|
||||
|
||||
setTimeout(() => {
|
||||
that.event.mouse_left(leftEvent)
|
||||
this.event.mouse_left(leftEvent)
|
||||
|
||||
that.event.mouse_right(rightEvent)
|
||||
this.event.mouse_right(rightEvent)
|
||||
|
||||
that.event.mouse_move((movement, cartesian) => {
|
||||
this.event.mouse_move((movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
that.renewPositions()
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
this.renewPositions()
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.endPosition.x,
|
||||
movement.endPosition.y
|
||||
)
|
||||
})
|
||||
|
||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||
let startTime = new Date()
|
||||
let pos = {
|
||||
position: {
|
||||
@ -2163,7 +1659,7 @@ class PincerArrowObject extends Base {
|
||||
y: (movement.position1.y + movement.position2.y) / 2
|
||||
}
|
||||
}
|
||||
that.event.gesture_pinck_end(() => {
|
||||
this.event.gesture_pinck_end(() => {
|
||||
let endTime = new Date()
|
||||
if (endTime - startTime >= 500) {
|
||||
// 长按取消
|
||||
@ -2178,23 +1674,23 @@ class PincerArrowObject extends Base {
|
||||
|
||||
let points = [[]]
|
||||
let pos84 = []
|
||||
for (let i = 0; i < that.positionsH.length; i++) {
|
||||
let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer)
|
||||
for (let i = 0; i < this.positionsH.length; i++) {
|
||||
let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer)
|
||||
pos84.push(position)
|
||||
points[0].push([position.lng, position.lat])
|
||||
}
|
||||
let position = that.cartesian3Towgs84(that.positionsH[0], that.sdk.viewer)
|
||||
let position = this.cartesian3Towgs84(this.positionsH[0], this.sdk.viewer)
|
||||
points[0].push([position.lng, position.lat])
|
||||
let polygon = turf.polygon(points)
|
||||
let centroid = turf.pointOnFeature(polygon)
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
that
|
||||
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||
this
|
||||
.getClampToHeight({
|
||||
lng: centroid.geometry.coordinates[0],
|
||||
lat: centroid.geometry.coordinates[1]
|
||||
}, objectsToExclude)
|
||||
.then(height => {
|
||||
that.label.position = [
|
||||
this.label.position = [
|
||||
centroid.geometry.coordinates[0],
|
||||
centroid.geometry.coordinates[1],
|
||||
height
|
||||
@ -2203,39 +1699,39 @@ class PincerArrowObject extends Base {
|
||||
createNodePoints()
|
||||
}, 200);
|
||||
async function createNodePoints() {
|
||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||
let objectsToExclude = [..._this.sdk.viewer.entities.values]
|
||||
for (let i = 0; i < optionsPositions.length; i++) {
|
||||
let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude)
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude)
|
||||
let entity = _this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: i,
|
||||
position: Cesium.Cartesian3.fromDegrees(optionsPositions[i].lng, optionsPositions[i].lat, height),
|
||||
billboard: {
|
||||
image: that.getSourceRootPath() + '/img/point.png',
|
||||
image: _this.getSourceRootPath() + '/img/point.png',
|
||||
width: 15,
|
||||
height: 15,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||
},
|
||||
})
|
||||
that.nodePoints.push(entity)
|
||||
_this.nodePoints.push(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
static closeNodeEdit(that) {
|
||||
closeNodeEdit() {
|
||||
YJ.Measure.SetMeasureStatus(false)
|
||||
that.event && that.event.destroy()
|
||||
that.tip && that.tip.destroy()
|
||||
that.tip = null
|
||||
this.event && this.event.destroy()
|
||||
this.tip && this.tip.destroy()
|
||||
this.tip = null
|
||||
|
||||
for (let i = 0; i < that.nodePoints.length; i++) {
|
||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
||||
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||
}
|
||||
that.nodePoints = []
|
||||
that.picking = true
|
||||
this.nodePoints = []
|
||||
this.picking = true
|
||||
}
|
||||
|
||||
setPosition(v) {
|
||||
@ -2673,8 +2169,8 @@ class PincerArrowObject extends Base {
|
||||
|
||||
// 计算投影面积
|
||||
if (!this.spreadState) {
|
||||
this.options.areaByMeter = this.computeArea(pos84)
|
||||
this.areaUnit = this.areaUnit
|
||||
this.areaByMeter = this.computeArea(pos84)
|
||||
this.areaChangeCallBack && this.areaChangeCallBack()
|
||||
}
|
||||
return fromDegreesArray
|
||||
}
|
||||
|
Reference in New Issue
Block a user