From ae48dbd70064ebc57dad31b3ef00ca0ec6903101 Mon Sep 17 00:00:00 2001 From: zh <972939975@qq.com> Date: Fri, 5 Sep 2025 18:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Obj/Base/AssembleObject/index.js | 721 ++---------- src/Obj/Base/AttackArrowObject/index.js | 658 ++--------- src/Obj/Base/BillboardObject/index.js | 850 ++------------ src/Obj/Base/CurvelineObject/index.js | 1122 +++++++----------- src/Obj/Base/LabelObject/index.js | 25 +- src/Obj/Base/PincerArrowObject/index.js | 702 ++--------- src/Obj/Base/PolygonObject/index.js | 953 +++------------ src/Obj/Base/PolylineObject/index.js | 1158 +++++++------------ src/Obj/Base/TextObject/GroundText/index.js | 75 +- src/Obj/Base/TextObject/StandText/index.js | 150 ++- src/Obj/Base/index.js | 21 +- src/Obj/Element/Dialog/eventBinding.js | 1 + src/Tools/index.js | 45 +- static/custom/css/index.css | 147 ++- 14 files changed, 1753 insertions(+), 4875 deletions(-) diff --git a/src/Obj/Base/AssembleObject/index.js b/src/Obj/Base/AssembleObject/index.js index e77a99b..06c4c67 100644 --- a/src/Obj/Base/AssembleObject/index.js +++ b/src/Obj/Base/AssembleObject/index.js @@ -28,7 +28,6 @@ class AssembleObject extends Base { * @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色 * @param options.height {number} 高度 * @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式) - * @param options.areaUnit='平方米' {string} 面积单位 * @param options.line {object} 边框 * @param options.line.width=2 {string} 边框宽 * @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色 @@ -80,7 +79,6 @@ class AssembleObject extends Base { this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' - this.options['area-unit'] = options['area-unit'] || '平方米' this.entity this.event = new MouseEvent(this.sdk) this.operate = {} @@ -105,13 +103,11 @@ class AssembleObject extends Base { this.options.attribute = options.attribute || {} this.options.attribute.link = this.options.attribute.link || {} this.options.attribute.link.content = this.options.attribute.link.content || [] - this.options.attribute.camera = this.options.attribute.camera || {} - this.options.attribute.camera.content = this.options.attribute.camera.content || [] - this.options.attribute.vr = this.options.attribute.vr || {} - this.options.attribute.vr.content = this.options.attribute.vr.content || [] - this.options.attribute.goods = this.options.attribute.goods || {} - this.options.attribute.goods.content = this.options.attribute.goods.content || [] - this.options.attributeType = options.attributeType || 'richText' + + delete this.options.attribute.camera + delete this.options.attribute.vr + delete this.options.attribute.goods + this.nodePoints = [] if (!this.options.positions || this.options.positions.length < 3) { this._error = '集结地最少需要三个坐标!' @@ -189,7 +185,7 @@ class AssembleObject extends Base { return } let heightModeName = '' - AssembleObject.closeNodeEdit(this) + this.closeNodeEdit() let ground = false let disabled = false this.renewPositions() @@ -314,45 +310,6 @@ class AssembleObject extends Base { }) } - get area() { - return this.options.area - } - - set area(v) { - this.options.area = v - this._elms.area && this._elms.area.forEach((item) => { - item.value = v - }) - } - - get areaUnit() { - return this.options['area-unit'] - } - set areaUnit(v) { - this.options['area-unit'] = v - this._elms.areaUnit && this._elms.areaUnit.forEach((item) => { - item.value = v - }) - if (this.options.areaByMeter) { - switch (v) { - case '平方米': - this.area = this.options.areaByMeter - break; - case '平方千米': - this.area = Number((this.options.areaByMeter / 1000000).toFixed(8)) - break; - case '亩': - this.area = Number((this.options.areaByMeter / 666.6666667).toFixed(4)) - break; - case '公顷': - this.area = Number((this.options.areaByMeter / 10000).toFixed(6)) - break; - default: - this.area = this.options.areaByMeter - } - } - } - get labelShow() { return this.options.label.show } @@ -564,319 +521,6 @@ class AssembleObject extends Base { } } - get attributeType() { - return this.options.attributeType - } - - set attributeType(v) { - this.options.attributeType = v - this._elms.attributeType && this._elms.attributeType.forEach((item) => { - item.value = v - }) - let attributeContent = this._DialogObject._element.content.getElementsByClassName('attribute-content') - for (let i = 0; i < attributeContent.length; i++) { - if (attributeContent[i].className.indexOf('attribute-content-' + v) > -1) { - attributeContent[i].style.display = 'block'; - } - else { - attributeContent[i].style.display = 'none'; - } - } - } - - get attributeLink() { - return this.options.attribute.link.content - } - - set attributeLink(v) { - this.options.attribute.link.content = v - if (!this._DialogObject || !this._DialogObject._element || !this._DialogObject._element.content || this._DialogObject._element.content.getElementsByClassName('attribute-content-link').length == 0) { - return - } - let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-link')[1].getElementsByClassName('table')[0] - let tableContent = table.getElementsByClassName('table-body')[0] - tableContent.innerHTML = '' - if (this.options.attribute.link.content.length > 0) { - table.getElementsByClassName('table-empty')[0].style.display = 'none' - } - else { - table.getElementsByClassName('table-empty')[0].style.display = 'flex' - } - for (let i = 0; i < this.options.attribute.link.content.length; i++) { - let tr = ` -
-
` + this.options.attribute.link.content[i].name + `
-
` + this.options.attribute.link.content[i].url + `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 = ` -
-
` + this.options.attribute.vr.content[i].name + `
-
` + this.options.attribute.vr.content[i].url + `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - item[i].innerHTML = html - let textareaElm = item[i].getElementsByClassName('link-edit')[0] - textareaElm.style.height = (height - 10) + 'px' - let td = item[i].getElementsByClassName('td') - td[0].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].name - td[1].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].url - let btn = item[i].getElementsByTagName('button') - for (let n = 0; n < btn.length; n++) { - if (!btn[n] || !btn[n].attributes) { - continue - } - for (let m of btn[n].attributes) { - if (m.name === '@click') { - btn[n].addEventListener('click', (e) => { - if (typeof (fun[m.value]) === 'function') { - fun[m.value]({ name: td[0].getElementsByClassName('input')[0].value, url: td[1].getElementsByClassName('input')[0].value }, i) - } - }); - btn[n].attributes.removeNamedItem(m.name) - break - } - } - } - break - } - } - }, - vrDelete: (i) => { - this.options.attribute.vr.content.splice(i, 1) - this.attributeVr = this.options.attribute.vr.content - }, - - confirmEdit: (value, i) => { - let name = value.name && value.name.replace(/\s/g, "") - let url = value.url && value.url.replace(/\s/g, "") - if (name && url) { - this.options.attribute.vr.content[i] = value - } - else { - window.ELEMENT && window.ELEMENT.Message({ - message: '名称或链接不能为空!', - type: 'warning', - duration: 1500 - }); - } - this.attributeVr = this.options.attribute.vr.content - }, - cancelEdit: () => { - this.attributeVr = this.options.attribute.vr.content - }, - fileSelect: (value, i) => { - let fileElm = item[i].getElementsByClassName('file-select')[0] - fileElm.click() - fileElm.removeEventListener('change', fileSelect) - fileElm.addEventListener('change', fileSelect) - } - } - let fileSelect = (event) => { - if (event.target.value) { - let td = item[event.target.getAttribute('index')].getElementsByClassName('td') - td[1].getElementsByClassName('input')[0].value = event.target.value - event.target.value = null - } - } - for (let i = 0; i < item.length; i++) { - let btn = item[i].getElementsByTagName('button') - for (let n = 0; n < btn.length; n++) { - if (!btn[n] || !btn[n].attributes) { - continue - } - for (let m of btn[n].attributes) { - if (m.name === '@click') { - btn[n].addEventListener('click', (e) => { - if (typeof (fun[m.value]) === 'function') { - fun[m.value](i) - } - }); - btn[n].attributes.removeNamedItem(m.name) - break - } - } - } - } - } - - get attributeGoods() { - return this.options.attribute.goods.content - } - - set attributeGoods(v) { - this.options.attribute.goods.content = v - } - static create(that) { let positions = that.options.positions let fromDegreesArray = [] @@ -919,9 +563,10 @@ class AssembleObject extends Base { break } - if (!that.options.label.position) { - that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height } - } + // if (!that.options.label.position) { + // that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height } + // } + that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height } let fromDegreesArray2 = [] for (let i = 0; i < points[0].length; i++) { @@ -939,7 +584,7 @@ class AssembleObject extends Base { color: that.options.color }) } - that.options.label.ground = ground + // that.options.label.ground = ground that.positionsH = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray2) that.entity = that.sdk.viewer.entities.add({ @@ -967,23 +612,8 @@ class AssembleObject extends Base { for (let i = 0; i < positionsA.length; i++) { pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer)) } - that.options.areaByMeter = that.computeArea(pos84); - switch (that.options['area-unit']) { - case '平方米': - that.options.area = that.options.areaByMeter - break; - case '平方千米': - that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8)) - break; - case '亩': - that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4)) - break; - case '公顷': - that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6)) - break; - default: - that.options.area = that.options.areaByMeter - } + that.areaByMeter = that.computeArea(pos84); + that.areaChangeCallBack && that.areaChangeCallBack() syncData(that.sdk, that.options.id) if (that.options.show) { setSplitDirection(0, that.options.id) @@ -1007,12 +637,13 @@ class AssembleObject extends Base { scaleByDistance: that.options.label.scaleByDistance, near: that.options.label.near, far: that.options.label.far, - ground: that.options.label.ground, + // ground: that.options.label.ground, }) } // 编辑框 async edit(state) { + return if (this._error) { return } @@ -1446,7 +1077,6 @@ class AssembleObject extends Base { if (unitDataLegpObject) { unitDataLegpObject.legp_search(unitData) let unitDataLegpElm = this._DialogObject._element.content.getElementsByClassName('input-select-unit')[0].getElementsByTagName('input')[0] - unitDataLegpElm.value = this.options['area-unit'] for (let i = 0; i < unitData.length; i++) { if (unitData[i].value === unitDataLegpElm.value) { unitDataLegpObject.legp_searchActive(unitData[i].value) @@ -1511,8 +1141,6 @@ class AssembleObject extends Base { this.color = this.originalOptions.color this.lineColor = this.originalOptions.line.color this.lineWidth = this.originalOptions.line.width - this.area = this.originalOptions.area - this.areaUnit = this.originalOptions['area-unit'] this.labelShow = this.originalOptions.label.show this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize @@ -1525,12 +1153,6 @@ class AssembleObject extends Base { this.labelLineColor = this.originalOptions.label.lineColor this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0] this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1] - this.attributeLink = this.options.attribute.link.content - this.attributeCamera = this.options.attribute.camera.content - this.attributeVr = this.options.attribute.vr.content - this.attributeGoods = this.options.attribute.goods.content - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() for (let i = 0; i < this.options.positions.length; i++) { @@ -1572,51 +1194,6 @@ class AssembleObject extends Base { await syncData(this.sdk, this.options.id) } - _addLink() { - // document.getElementsByClassName - if (this._DialogObject._element.content.getElementsByClassName('link_add')[0] && this._DialogObject._element.content.getElementsByClassName('link_add')[0].value) { - this.options.attribute.link.content.push({ - name: '链接', - url: this._DialogObject._element.content.getElementsByClassName('link_add')[0].value - }) - this._DialogObject._element.content.getElementsByClassName('link_add')[0].value = '' - this.attributeLink = this.options.attribute.link.content - } - else { - this.Dialog.clickAddLink && this.Dialog.clickAddLink() - } - } - - addAttributeLink(link) { - this.options.attribute.link.content.push({ - name: '链接', - url: link - }) - this.attributeLink = this.options.attribute.link.content - } - - _addRr() { - if (this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value) { - this.options.attribute.vr.content.push({ - name: '全景图' , - url: this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value - }) - this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value = '' - this.attributeVr = this.options.attribute.vr.content - } - else { - this.Dialog.clickAddVr && this.Dialog.clickAddVr() - } - } - - addAttributeRr(vr) { - this.options.attribute.vr.content.push({ - name: '全景图' , - url: vr - }) - this.attributeVr = this.options.attribute.vr.content - } - /** * 飞到 */ @@ -1818,6 +1395,11 @@ class AssembleObject extends Base { this.positions = newpositions this.previous = null this.positionEditing = false + + if(this._positionEditingCallback) { + this._positionEditingCallback() + this._positionEditingCallback = null + } }) this.event.mouse_right((movement, cartesian) => { this.positionEditing = false @@ -1919,131 +1501,47 @@ class AssembleObject extends Base { get positionEditing() { return this.operate.positionEditing } - - static EventBinding(that, elements) { - for (let i = 0; i < elements.length; i++) { - let Event = [] - let isEvent = false - let removeName = [] - if (!elements[i] || !elements[i].attributes) { - continue; - } - for (let m of elements[i].attributes) { - switch (m.name) { - case '@model': { - isEvent = true - if (elements[i].type == 'checkbox') { - Event.push((e) => { that[m.value] = e.target.checked }) - elements[i].checked = that[m.value] - } - else { - Event.push((e) => { - let value = e.target.value - if (e.target.type == 'number') { - if (e.data != '.' && (e.data != '-' || e.target.value)) { - value = Number(value) - if ((e.target.max) && value > Number(e.target.max)) { - value = Number(e.target.max) - } - if ((e.target.min) && value < Number(e.target.min)) { - value = Number(e.target.min) - } - that[m.value] = value - } - } - else { - that[m.value] = value - } - }) - if (elements[i].nodeName == 'IMG') { - elements[i].src = that[m.value] - } - else { - elements[i].value = that[m.value] - } - } - if (that._elms[m.value]) { - that._elms[m.value].push(elements[i]) - } - else { - that._elms[m.value] = [elements[i]] - } - removeName.push(m.name) - break; - } - case '@click': { - elements[i].addEventListener('click', (e) => { - if (typeof (that[m.value]) === 'function') { - that[m.value](e) - } - }); - removeName.push(m.name) - // elements[i].attributes.removeNamedItem(m.name) - break; - } - case '@change': { - isEvent = true - Event.push((e) => { - let value = e.target.value - if (e.target.type == 'number' && value != '') { - value = Number(value) - e.target.value = value - } - if (typeof (that[m.value]) === 'function') { - that[m.value](e, value) - } - }) - break; - } - } - // elements[i].attributes[m] = undefined - } - for (let n = 0; n < removeName.length; n++) { - elements[i].attributes.removeNamedItem(removeName[n]) - } - - if (isEvent) { - let ventType = 'input' - if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') { - ventType = 'change' - } - elements[i].addEventListener(ventType, (e) => { - for (let t = 0; t < Event.length; t++) { - Event[t](e) - } - }); - } - } + openPositionEditing(cd) { + this.positionEditing = true + this._positionEditingCallback = cd + } + get areaChangeCallBack() { + return this._areaChangeCallBack } - static nodeEdit(that, cb = () => { }) { - that.positionEditing = false + set areaChangeCallBack (cd) { + this._areaChangeCallBack = cd + } + + nodeEdit(cb = () => { }) { + this.positionEditing = false if (YJ.Measure.GetMeasureStatus()) { cb('上一次测量未结束') } else { YJ.Measure.SetMeasureStatus(true) - that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk) - that.event = new MouseEvent(that.sdk) - that.nodePoints = [] + let _this = this + this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk) + this.event = new MouseEvent(this.sdk) + this.nodePoints = [] let selectPoint let originalPosition let fromDegreesArray = [] - for (let i = 0; i < that.options.positions.length; i++) { - fromDegreesArray.push(that.options.positions[i].lng, that.options.positions[i].lat) + for (let i = 0; i < this.options.positions.length; i++) { + fromDegreesArray.push(this.options.positions[i].lng, this.options.positions[i].lat) } let moveEvent = (movement, cartesian) => { if (selectPoint) { - that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer) - if (that._elms.lng && that._elms.lng[selectPoint.index]) { - that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8) + this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer) + if (this._elms.lng && this._elms.lng[selectPoint.index]) { + this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8) } - if (that._elms.lat && that._elms.lat[selectPoint.index]) { - that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8) + if (this._elms.lat && this._elms.lat[selectPoint.index]) { + this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8) } - that.renewPositions() + this.renewPositions() } - that.tip.setPosition( + this.tip.setPosition( cartesian, movement.position ? movement.position.x : movement.endPosition.x, movement.position ? movement.position.y : movement.endPosition.y @@ -2052,25 +1550,25 @@ class AssembleObject extends Base { let leftEvent = (movement, cartesian) => { moveEvent(movement, cartesian) - let position84 = that.cartesian3Towgs84(cartesian, that.sdk.viewer) + let position84 = this.cartesian3Towgs84(cartesian, this.sdk.viewer) if (selectPoint) { let index = selectPoint.index - let entity = that.sdk.viewer.entities.add({ + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: index, - position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, position84.alt), + position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, position84.alt), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) }, }) - that.nodePoints.splice(selectPoint.index, 0, entity) + this.nodePoints.splice(selectPoint.index, 0, entity) selectPoint = null - that.tip.set_text('请选择一个顶点,右键取消') + this.tip.set_text('请选择一个顶点,右键取消') } else { let position = movement.position @@ -2080,49 +1578,50 @@ class AssembleObject extends Base { y: (movement.position1.y + movement.position2.y) / 2 } } - var pick = that.sdk.viewer.scene.pick(position); + var pick = this.sdk.viewer.scene.pick(position); if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') { selectPoint = pick.id - originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer) - that.nodePoints.splice(pick.id.index, 1) - that.sdk.viewer.entities.remove(pick.id) - that.tip.set_text('左键确认,右键取消') + originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer) + this.nodePoints.splice(pick.id.index, 1) + this.sdk.viewer.entities.remove(pick.id) + this.tip.set_text('左键确认,右键取消') } } - that.renewPositions() + this.renewPositions() + cb('', [...this.options.positions]) } let rightEvent = () => { - that.event.mouse_move(() => { }) - that.event.mouse_left(() => { }) - that.event.mouse_right(() => { }) - that.event.gesture_pinck_start(() => { }) + this.event.mouse_move(() => { }) + this.event.mouse_left(() => { }) + this.event.mouse_right(() => { }) + this.event.gesture_pinck_start(() => { }) if (selectPoint) { if (!originalPosition) { - that.options.positions.pop() + this.options.positions.pop() } else { - that.options.positions[selectPoint.index] = originalPosition + this.options.positions[selectPoint.index] = originalPosition } - if (that._elms.lng && that._elms.lng[selectPoint.index]) { - that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8) + if (this._elms.lng && this._elms.lng[selectPoint.index]) { + this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8) } - if (that._elms.lat && that._elms.lat[selectPoint.index]) { - that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8) + if (this._elms.lat && this._elms.lat[selectPoint.index]) { + this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8) } } - that.heightMode = that.heightMode - that.previous = null + this.heightMode = this.heightMode + this.previous = null } - that.entity.polyline.clampToGround = true - that.entity.polyline.arcType = Cesium.ArcType.GEODESIC - that.entity.polygon.perPositionHeight = false - that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () { - let arr = that.computeAssemble(that.options.positions) + this.entity.polyline.clampToGround = true + this.entity.polyline.arcType = Cesium.ArcType.GEODESIC + this.entity.polygon.perPositionHeight = false + this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () { + let arr = _this.computeAssemble(_this.options.positions) return new Cesium.PolygonHierarchy(arr) }, false) - that.entity.polyline.positions = new Cesium.CallbackProperty(function () { - let arr = that.computeAssemble(that.options.positions) + this.entity.polyline.positions = new Cesium.CallbackProperty(function () { + let arr = _this.computeAssemble(_this.options.positions) if (arr.length >= 3) { return [...arr, arr[0], arr[1]] } @@ -2134,23 +1633,23 @@ class AssembleObject extends Base { let points = [[]] let pos84 = [] - for (let i = 0; i < that.positionsH.length; i++) { - let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer) + for (let i = 0; i < this.positionsH.length; i++) { + let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer) pos84.push(position) points[0].push([position.lng, position.lat]) } - let position = that.cartesian3Towgs84(that.positionsH[0], that.sdk.viewer) + let position = this.cartesian3Towgs84(this.positionsH[0], this.sdk.viewer) points[0].push([position.lng, position.lat]) let polygon = turf.polygon(points) let centroid = turf.pointOnFeature(polygon) - let objectsToExclude = [...that.sdk.viewer.entities.values] - that + let objectsToExclude = [...this.sdk.viewer.entities.values] + this .getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }, objectsToExclude) .then(height => { - that.label.position = [ + this.label.position = [ centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height @@ -2159,15 +1658,15 @@ class AssembleObject extends Base { setTimeout(() => { - that.event.mouse_left(leftEvent) + this.event.mouse_left(leftEvent) - that.event.mouse_right(rightEvent) + this.event.mouse_right(rightEvent) - that.event.mouse_move(moveEvent) + this.event.mouse_move(moveEvent) - that.event.gesture_pinck_start((movement, cartesian) => { + this.event.gesture_pinck_start((movement, cartesian) => { let startTime = new Date() - that.event.gesture_pinck_end(() => { + this.event.gesture_pinck_end(() => { let endTime = new Date() let pos = { position: { @@ -2187,31 +1686,31 @@ class AssembleObject extends Base { createNodePoints() }, 200); async function createNodePoints() { - let objectsToExclude = [...that.sdk.viewer.entities.values] - for (let i = 0; i < that.options.positions.length; i++) { - let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude) - let entity = that.sdk.viewer.entities.add({ + let objectsToExclude = [..._this.sdk.viewer.entities.values] + for (let i = 0; i < _this.options.positions.length; i++) { + let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude) + let entity = _this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: i, - position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat, height), + position: Cesium.Cartesian3.fromDegrees(_this.options.positions[i].lng, _this.options.positions[i].lat, height), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: _this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) }, }) - that.nodePoints.push(entity) + _this.nodePoints.push(entity) } } - // for (let i = 0; i < that.options.positions.length; i++) { - // let entity = that.sdk.viewer.entities.add({ + // for (let i = 0; i < this.options.positions.length; i++) { + // let entity = this.sdk.viewer.entities.add({ // name: 'node-secondary-edit-point', // index: i, - // position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat), + // position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat), // billboard: { - // image: that.getSourceRootPath() + '/img/point.png', + // image: this.getSourceRootPath() + '/img/point.png', // width: 15, // height: 15, // disableDepthTestDistance: Number.POSITIVE_INFINITY, @@ -2222,17 +1721,17 @@ class AssembleObject extends Base { } } - static closeNodeEdit(that) { + closeNodeEdit() { YJ.Measure.SetMeasureStatus(false) - that.event && that.event.destroy() - that.tip && that.tip.destroy() - that.tip = null + this.event && this.event.destroy() + this.tip && this.tip.destroy() + this.tip = null - for (let i = 0; i < that.nodePoints.length; i++) { - that.sdk.viewer.entities.remove(that.nodePoints[i]) + for (let i = 0; i < this.nodePoints.length; i++) { + this.sdk.viewer.entities.remove(this.nodePoints[i]) } - that.nodePoints = [] - that.picking = true + this.nodePoints = [] + this.picking = true } setPosition(v) { @@ -2323,7 +1822,7 @@ class AssembleObject extends Base { } // 更新坐标 - renewPositions(position84) { + renewPositions(position84, cd) { if (this._error || !this.sdk.viewer) { return } @@ -2410,8 +1909,8 @@ class AssembleObject extends Base { } // 计算投影面积 - this.options.areaByMeter = this.computeArea(pos84) - this.areaUnit = this.areaUnit + this.areaByMeter = this.computeArea(pos84) + this.areaChangeCallBack && this.areaChangeCallBack() return fromDegreesArray } } diff --git a/src/Obj/Base/AttackArrowObject/index.js b/src/Obj/Base/AttackArrowObject/index.js index 66ae18a..b0c8b0b 100644 --- a/src/Obj/Base/AttackArrowObject/index.js +++ b/src/Obj/Base/AttackArrowObject/index.js @@ -83,7 +83,6 @@ class AttackArrowObject extends Base { this.options.line = options.line || {} this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' - this.options['area-unit'] = options['area-unit'] || '平方米' this.entity this.event = new MouseEvent(this.sdk) this.operate = {} @@ -112,13 +111,11 @@ class AttackArrowObject extends Base { this.options.attribute = options.attribute || {} this.options.attribute.link = this.options.attribute.link || {} this.options.attribute.link.content = this.options.attribute.link.content || [] - this.options.attribute.camera = this.options.attribute.camera || {} - this.options.attribute.camera.content = this.options.attribute.camera.content || [] - this.options.attribute.vr = this.options.attribute.vr || {} - this.options.attribute.vr.content = this.options.attribute.vr.content || [] - this.options.attribute.goods = this.options.attribute.goods || {} - this.options.attribute.goods.content = this.options.attribute.goods.content || [] - this.options.attributeType = options.attributeType || 'richText' + + delete this.options.attribute.camera + delete this.options.attribute.vr + delete this.options.attribute.goods + if (!this.options.positions || this.options.positions.length < 3) { this._error = '箭头面最少需要三个坐标!' @@ -196,7 +193,7 @@ class AttackArrowObject extends Base { return } let heightModeName = '' - AttackArrowObject.closeNodeEdit(this) + this.closeNodeEdit() let ground = false let disabled = false this.renewPositions() @@ -322,45 +319,6 @@ class AttackArrowObject extends Base { }) } - get area() { - return this.options.area - } - - set area(v) { - this.options.area = v - this._elms.area && this._elms.area.forEach((item) => { - item.value = v - }) - } - - get areaUnit() { - return this.options['area-unit'] - } - set areaUnit(v) { - this.options['area-unit'] = v - this._elms.areaUnit && this._elms.areaUnit.forEach((item) => { - item.value = v - }) - if (this.options.areaByMeter) { - switch (v) { - case '平方米': - this.area = this.options.areaByMeter - break; - case '平方千米': - this.area = Number((this.options.areaByMeter / 1000000).toFixed(8)) - break; - case '亩': - this.area = Number((this.options.areaByMeter / 666.6666667).toFixed(4)) - break; - case '公顷': - this.area = Number((this.options.areaByMeter / 10000).toFixed(6)) - break; - default: - this.area = this.options.areaByMeter - } - } - } - get labelShow() { return this.options.label.show } @@ -572,319 +530,6 @@ class AttackArrowObject extends Base { } } - get attributeType() { - return this.options.attributeType - } - - set attributeType(v) { - this.options.attributeType = v - this._elms.attributeType && this._elms.attributeType.forEach((item) => { - item.value = v - }) - let attributeContent = this._DialogObject._element.content.getElementsByClassName('attribute-content') - for (let i = 0; i < attributeContent.length; i++) { - if (attributeContent[i].className.indexOf('attribute-content-' + v) > -1) { - attributeContent[i].style.display = 'block'; - } - else { - attributeContent[i].style.display = 'none'; - } - } - } - - get attributeLink() { - return this.options.attribute.link.content - } - - set attributeLink(v) { - this.options.attribute.link.content = v - if (!this._DialogObject || !this._DialogObject._element || !this._DialogObject._element.content || this._DialogObject._element.content.getElementsByClassName('attribute-content-link').length == 0) { - return - } - let table = this._DialogObject._element.content.getElementsByClassName('attribute-content-link')[1].getElementsByClassName('table')[0] - let tableContent = table.getElementsByClassName('table-body')[0] - tableContent.innerHTML = '' - if (this.options.attribute.link.content.length > 0) { - table.getElementsByClassName('table-empty')[0].style.display = 'none' - } - else { - table.getElementsByClassName('table-empty')[0].style.display = 'flex' - } - for (let i = 0; i < this.options.attribute.link.content.length; i++) { - let tr = ` -
-
` + this.options.attribute.link.content[i].name + `
-
` + this.options.attribute.link.content[i].url + `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 = ` -
-
` + this.options.attribute.vr.content[i].name + `
-
` + this.options.attribute.vr.content[i].url + `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - item[i].innerHTML = html - let textareaElm = item[i].getElementsByClassName('link-edit')[0] - textareaElm.style.height = (height - 10) + 'px' - let td = item[i].getElementsByClassName('td') - td[0].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].name - td[1].getElementsByClassName('input')[0].value = this.options.attribute.vr.content[index].url - let btn = item[i].getElementsByTagName('button') - for (let n = 0; n < btn.length; n++) { - if (!btn[n] || !btn[n].attributes) { - continue - } - for (let m of btn[n].attributes) { - if (m.name === '@click') { - btn[n].addEventListener('click', (e) => { - if (typeof (fun[m.value]) === 'function') { - fun[m.value]({ name: td[0].getElementsByClassName('input')[0].value, url: td[1].getElementsByClassName('input')[0].value }, i) - } - }); - btn[n].attributes.removeNamedItem(m.name) - break - } - } - } - break - } - } - }, - vrDelete: (i) => { - this.options.attribute.vr.content.splice(i, 1) - this.attributeVr = this.options.attribute.vr.content - }, - - confirmEdit: (value, i) => { - let name = value.name && value.name.replace(/\s/g, "") - let url = value.url && value.url.replace(/\s/g, "") - if (name && url) { - this.options.attribute.vr.content[i] = value - } - else { - window.ELEMENT && window.ELEMENT.Message({ - message: '名称或链接不能为空!', - type: 'warning', - duration: 1500 - }); - } - this.attributeVr = this.options.attribute.vr.content - }, - cancelEdit: () => { - this.attributeVr = this.options.attribute.vr.content - }, - fileSelect: (value, i) => { - let fileElm = item[i].getElementsByClassName('file-select')[0] - fileElm.click() - fileElm.removeEventListener('change', fileSelect) - fileElm.addEventListener('change', fileSelect) - } - } - let fileSelect = (event) => { - if (event.target.value) { - let td = item[event.target.getAttribute('index')].getElementsByClassName('td') - td[1].getElementsByClassName('input')[0].value = event.target.value - event.target.value = null - } - } - for (let i = 0; i < item.length; i++) { - let btn = item[i].getElementsByTagName('button') - for (let n = 0; n < btn.length; n++) { - if (!btn[n] || !btn[n].attributes) { - continue - } - for (let m of btn[n].attributes) { - if (m.name === '@click') { - btn[n].addEventListener('click', (e) => { - if (typeof (fun[m.value]) === 'function') { - fun[m.value](i) - } - }); - btn[n].attributes.removeNamedItem(m.name) - break - } - } - } - } - } - - get attributeGoods() { - return this.options.attribute.goods.content - } - - set attributeGoods(v) { - this.options.attribute.goods.content = v - } - static create(that) { let positions = that.options.positions let fromDegreesArray = [] @@ -928,10 +573,11 @@ class AttackArrowObject extends Base { break } - if (!that.options.label.position) { - that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height } - } - that.options.label.ground = ground + // if (!that.options.label.position) { + // that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height } + // } + that.options.label.position = { lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1], alt: that.height + height } + // that.options.label.ground = ground let fromDegreesArray2 = [] for (let i = 0; i < points[0].length; i++) { @@ -977,23 +623,8 @@ class AttackArrowObject extends Base { for (let i = 0; i < positionsA.length; i++) { pos84.push(that.cartesian3Towgs84(positionsA[i], that.sdk.viewer)) } - that.options.areaByMeter = that.computeArea(pos84); - switch (that.options['area-unit']) { - case '平方米': - that.options.area = that.options.areaByMeter - break; - case '平方千米': - that.options.area = Number((that.options.areaByMeter / 1000000).toFixed(8)) - break; - case '亩': - that.options.area = Number((that.options.areaByMeter / 666.6666667).toFixed(4)) - break; - case '公顷': - that.options.area = Number((that.options.areaByMeter / 10000).toFixed(6)) - break; - default: - that.options.area = that.options.areaByMeter - } + that.areaByMeter = that.computeArea(pos84); + that.areaChangeCallBack && that.areaChangeCallBack() syncData(that.sdk, that.options.id) if (that.options.show) { @@ -1020,12 +651,13 @@ class AttackArrowObject extends Base { scaleByDistance: that.options.label.scaleByDistance, near: that.options.label.near, far: that.options.label.far, - ground: that.options.label.ground, + // ground: that.options.label.ground, }) } // 编辑框 async edit(state) { + return if (this._error) { return } @@ -1527,8 +1159,6 @@ class AttackArrowObject extends Base { this.color = this.originalOptions.color this.lineColor = this.originalOptions.line.color this.lineWidth = this.originalOptions.line.width - this.area = this.originalOptions.area - this.areaUnit = this.originalOptions['area-unit'] this.labelShow = this.originalOptions.label.show this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize @@ -1541,12 +1171,6 @@ class AttackArrowObject extends Base { this.labelLineColor = this.originalOptions.label.lineColor this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0] this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1] - this.attributeLink = this.options.attribute.link.content - this.attributeVr = this.options.attribute.vr.content - this.attributeCamera = this.options.attribute.camera.content - this.attributeGoods = this.options.attribute.goods.content - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() for (let i = 0; i < this.options.positions.length; i++) { if (this._elms.lng && this._elms.lng[i]) { @@ -1597,51 +1221,6 @@ class AttackArrowObject extends Base { await syncData(this.sdk, this.options.id) } - _addLink() { - // document.getElementsByClassName - if (this._DialogObject._element.content.getElementsByClassName('link_add')[0] && this._DialogObject._element.content.getElementsByClassName('link_add')[0].value) { - this.options.attribute.link.content.push({ - name: '链接', - url: this._DialogObject._element.content.getElementsByClassName('link_add')[0].value - }) - this._DialogObject._element.content.getElementsByClassName('link_add')[0].value = '' - this.attributeLink = this.options.attribute.link.content - } - else { - this.Dialog.clickAddLink && this.Dialog.clickAddLink() - } - } - - addAttributeLink(link) { - this.options.attribute.link.content.push({ - name: '链接', - url: link - }) - this.attributeLink = this.options.attribute.link.content - } - - _addRr() { - if (this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value) { - this.options.attribute.vr.content.push({ - name: '全景图' , - url: this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value - }) - this._DialogObject._element.content.getElementsByClassName('vr_add')[0].value = '' - this.attributeVr = this.options.attribute.vr.content - } - else { - this.Dialog.clickAddVr && this.Dialog.clickAddVr() - } - } - - addAttributeRr(vr) { - this.options.attribute.vr.content.push({ - name: '全景图' , - url: vr - }) - this.attributeVr = this.options.attribute.vr.content - } - /** * 飞到 */ @@ -1747,16 +1326,6 @@ class AttackArrowObject extends Base { } } - /** - * 打开富文本框 - */ - openRichTextEditor(e) { - // var ue = UE.getEditor('app'); - richText.open(this.options.id, this.options.name, this.options.richTextContent) - richText.primaryCallBack = (content) => { - this.options.richTextContent = content - } - } /**@desc 打开平移功能 * @@ -1844,6 +1413,11 @@ class AttackArrowObject extends Base { positions: [...this.positions] } this.positionEditing = false + + if(this._positionEditingCallback) { + this._positionEditingCallback() + this._positionEditingCallback = null + } }) this.event.mouse_right((movement, cartesian) => { this.positionEditing = false @@ -1946,6 +1520,18 @@ class AttackArrowObject extends Base { return this.operate.positionEditing } + openPositionEditing(cd) { + this.positionEditing = true + this._positionEditingCallback = cd + } + get areaChangeCallBack() { + return this._areaChangeCallBack + } + + set areaChangeCallBack (cd) { + this._areaChangeCallBack = cd + } + static EventBinding(that, elements) { for (let i = 0; i < elements.length; i++) { let Event = [] @@ -2045,28 +1631,29 @@ class AttackArrowObject extends Base { } } - static nodeEdit(that, cb = () => { }) { - that.positionEditing = false + nodeEdit(cb = () => { }) { + this.positionEditing = false setTimeout(() => { if (YJ.Measure.GetMeasureStatus()) { cb('上一次测量未结束') } else { - that.removeAnimate() + this.removeAnimate() YJ.Measure.SetMeasureStatus(true) - that.event && that.event.destroy() - that.tip && that.tip.destroy() - that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk) - that.event = new MouseEvent(that.sdk) - that.nodePoints = [] + let _this = this + this.event && this.event.destroy() + this.tip && this.tip.destroy() + this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk) + this.event = new MouseEvent(this.sdk) + this.nodePoints = [] let selectPoint let originalPosition let moveEvent = (movement, cartesian) => { if (selectPoint) { - that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer) - that.renewPositions() + this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer) + this.renewPositions() } - that.tip.setPosition( + this.tip.setPosition( cartesian, movement.position ? movement.position.x : movement.endPosition.x, movement.position ? movement.position.y : movement.endPosition.y @@ -2075,17 +1662,17 @@ class AttackArrowObject extends Base { let leftEvent = (movement, cartesian) => { moveEvent(movement, cartesian) if (selectPoint) { - that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer) + this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer) let index = selectPoint.index - if (selectPoint.index === that.options.positions.length - 1) { + if (selectPoint.index === this.options.positions.length - 1) { index = index + 1 } - let entity = that.sdk.viewer.entities.add({ + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: index, - position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, that.options.positions[selectPoint.index].alt), + position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, this.options.positions[selectPoint.index].alt), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, @@ -2094,86 +1681,87 @@ class AttackArrowObject extends Base { }) selectPoint = entity - originalPosition = that.options.positions[selectPoint.index] - that.nodePoints.splice(selectPoint.index, 0, entity) + originalPosition = this.options.positions[selectPoint.index] + this.nodePoints.splice(selectPoint.index, 0, entity) - if (index < that.options.positions.length) { + if (index < this.options.positions.length) { selectPoint = null - that.tip.set_text('请选择一个顶点,右键取消') + this.tip.set_text('请选择一个顶点,右键取消') } else { - that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index]) - that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer) + this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index]) + this.options.positions[selectPoint.index] = this.cartesian3Towgs84(cartesian, this.sdk.viewer) } - that.renewPositions() + this.renewPositions() + cb('', [...this.options.positions]) } else { - var pick = that.sdk.viewer.scene.pick(movement.position || movement.endPosition); + var pick = this.sdk.viewer.scene.pick(movement.position || movement.endPosition); if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') { selectPoint = pick.id - originalPosition = that.cartesian3Towgs84(pick.id.position.getValue(), that.sdk.viewer) - that.nodePoints.splice(pick.id.index, 1) - that.sdk.viewer.entities.remove(pick.id) - that.tip.set_text('左键确认,右键结束,CTRL+右键撤销') + originalPosition = this.cartesian3Towgs84(pick.id.position.getValue(), this.sdk.viewer) + this.nodePoints.splice(pick.id.index, 1) + this.sdk.viewer.entities.remove(pick.id) + this.tip.set_text('左键确认,右键结束,CTRL+右键撤销') } } } let rightEvent = (movement, cartesian) => { - that.event.mouse_move(() => { }) - that.event.mouse_left(() => { }) - that.event.mouse_right(() => { }) - that.event.gesture_pinck_start(() => { }) + this.event.mouse_move(() => { }) + this.event.mouse_left(() => { }) + this.event.mouse_right(() => { }) + this.event.gesture_pinck_start(() => { }) if (selectPoint) { if (!originalPosition) { - that.options.positions.pop() + this.options.positions.pop() } else { - that.options.positions[selectPoint.index] = originalPosition - if (that.options.positions.length > 3 && selectPoint.index === that.options.positions.length - 1) { - that.options.positions.splice(selectPoint.index + 1, 1) + this.options.positions[selectPoint.index] = originalPosition + if (this.options.positions.length > 3 && selectPoint.index === this.options.positions.length - 1) { + this.options.positions.splice(selectPoint.index + 1, 1) } } - if (that._elms.lng && that._elms.lng[selectPoint.index]) { - that._elms.lng[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lng.toFixed(8) + if (this._elms.lng && this._elms.lng[selectPoint.index]) { + this._elms.lng[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lng.toFixed(8) } - if (that._elms.lat && that._elms.lat[selectPoint.index]) { - that._elms.lat[selectPoint.index].innerHTML = that.options.positions[selectPoint.index].lat.toFixed(8) + if (this._elms.lat && this._elms.lat[selectPoint.index]) { + this._elms.lat[selectPoint.index].innerHTML = this.options.positions[selectPoint.index].lat.toFixed(8) } } - that.heightMode = that.heightMode - that.previous = null + this.heightMode = this.heightMode + this.previous = null } - that.entity.polyline.clampToGround = true - that.entity.polyline.arcType = Cesium.ArcType.GEODESIC - that.entity.polygon.perPositionHeight = false - that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () { - return new Cesium.PolygonHierarchy(that.positionsH) + this.entity.polyline.clampToGround = true + this.entity.polyline.arcType = Cesium.ArcType.GEODESIC + this.entity.polygon.perPositionHeight = false + this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () { + return new Cesium.PolygonHierarchy(_this.positionsH) }, false) - that.entity.polyline.positions = new Cesium.CallbackProperty(function () { - return [...that.positionsH, that.positionsH[0], that.positionsH[1]] + this.entity.polyline.positions = new Cesium.CallbackProperty(function () { + return [..._this.positionsH, _this.positionsH[0], _this.positionsH[1]] }, false) let points = [[]] let pos84 = [] - for (let i = 0; i < that.positionsH.length; i++) { - let position = that.cartesian3Towgs84(that.positionsH[i], that.sdk.viewer) + for (let i = 0; i < this.positionsH.length; i++) { + let position = this.cartesian3Towgs84(this.positionsH[i], this.sdk.viewer) pos84.push(position) points[0].push([position.lng, position.lat]) } - let position = that.cartesian3Towgs84(that.positionsH[0], that.sdk.viewer) + let position = this.cartesian3Towgs84(this.positionsH[0], this.sdk.viewer) points[0].push([position.lng, position.lat]) let polygon = turf.polygon(points) let centroid = turf.pointOnFeature(polygon) - let objectsToExclude = [...that.sdk.viewer.entities.values] - that + let objectsToExclude = [...this.sdk.viewer.entities.values] + this .getClampToHeight({ lng: centroid.geometry.coordinates[0], lat: centroid.geometry.coordinates[1] }, objectsToExclude) .then(height => { - that.label.position = [ + this.label.position = [ centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], height @@ -2181,36 +1769,36 @@ class AttackArrowObject extends Base { }) setTimeout(() => { - that.event.mouse_left(leftEvent) + this.event.mouse_left(leftEvent) - that.event.mouse_right(rightEvent) + this.event.mouse_right(rightEvent) - that.event.mouse_move(moveEvent) + this.event.mouse_move(moveEvent) - that.event.mouse_right_keyboard_ctrl((movement, cartesian) => { + this.event.mouse_right_keyboard_ctrl((movement, cartesian) => { if (selectPoint) { - that.options.positions.pop() - that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1]) - that.nodePoints.pop() + this.options.positions.pop() + this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1]) + this.nodePoints.pop() if (!selectPoint.index) { // selectPoint = null } - else if (selectPoint.index === that.options.positions.length) { - if (that.nodePoints[selectPoint.index - 1]) { - selectPoint = that.nodePoints[selectPoint.index - 1] + else if (selectPoint.index === this.options.positions.length) { + if (this.nodePoints[selectPoint.index - 1]) { + selectPoint = this.nodePoints[selectPoint.index - 1] } else { selectPoint.index = selectPoint.index - 1 } } - that.renewPositions() + this.renewPositions() } }) - that.event.gesture_pinck_start((movement, cartesian) => { + this.event.gesture_pinck_start((movement, cartesian) => { let startTime = new Date() - that.event.gesture_pinck_end(() => { + this.event.gesture_pinck_end(() => { let endTime = new Date() let pos = { position: { @@ -2230,31 +1818,31 @@ class AttackArrowObject extends Base { createNodePoints() }, 200); async function createNodePoints() { - let objectsToExclude = [...that.sdk.viewer.entities.values] - for (let i = 0; i < that.options.positions.length; i++) { - let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude) - let entity = that.sdk.viewer.entities.add({ + let objectsToExclude = [..._this.sdk.viewer.entities.values] + for (let i = 0; i < _this.options.positions.length; i++) { + let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude) + let entity = _this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: i, - position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat, height), + position: Cesium.Cartesian3.fromDegrees(_this.options.positions[i].lng, _this.options.positions[i].lat, height), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: _this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) }, }) - that.nodePoints.push(entity) + _this.nodePoints.push(entity) } } - // for (let i = 0; i < that.options.positions.length; i++) { - // let entity = that.sdk.viewer.entities.add({ + // for (let i = 0; i < this.options.positions.length; i++) { + // let entity = this.sdk.viewer.entities.add({ // name: 'node-secondary-edit-point', // index: i, - // position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat), + // position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat), // billboard: { - // image: that.getSourceRootPath() + '/img/point.png', + // image: this.getSourceRootPath() + '/img/point.png', // width: 15, // height: 15, // disableDepthTestDistance: Number.POSITIVE_INFINITY, @@ -2266,17 +1854,17 @@ class AttackArrowObject extends Base { }, 0); } - static closeNodeEdit(that) { + closeNodeEdit() { YJ.Measure.SetMeasureStatus(false) - that.event && that.event.destroy() - that.tip && that.tip.destroy() - that.tip = null + this.event && this.event.destroy() + this.tip && this.tip.destroy() + this.tip = null - for (let i = 0; i < that.nodePoints.length; i++) { - that.sdk.viewer.entities.remove(that.nodePoints[i]) + for (let i = 0; i < this.nodePoints.length; i++) { + this.sdk.viewer.entities.remove(this.nodePoints[i]) } - that.nodePoints = [] - that.picking = true + this.nodePoints = [] + this.picking = true } setPosition(v) { @@ -2679,8 +2267,8 @@ class AttackArrowObject extends Base { // 计算投影面积 if (!this.spreadState) { - this.options.areaByMeter = this.computeArea(pos84) - this.areaUnit = this.areaUnit + this.areaByMeter = this.computeArea(pos84) + this.areaChangeCallBack && this.areaChangeCallBack() } return fromDegreesArray } diff --git a/src/Obj/Base/BillboardObject/index.js b/src/Obj/Base/BillboardObject/index.js index 0157562..c3e008e 100644 --- a/src/Obj/Base/BillboardObject/index.js +++ b/src/Obj/Base/BillboardObject/index.js @@ -41,11 +41,7 @@ import { import { getGoodsList } from '../../../Tools/getGoodsList' class BillboardObject extends Base { - #_postRenderEvent = null - #_destroyMouseEvent = null - #_billboardHeight = 0 - - + #_positionEditingCallback = null /** * @constructor * @description 点标注 @@ -83,8 +79,8 @@ class BillboardObject extends Base { * @param options.attribute.vr.content[].url {string} 地址 * @param {object} ptions.attribute.camera={} 摄像头 * @param options.attribute.camera.content=[]] {array} 摄像头内容 - * @param {object} options.attribute.ISC={} ISC - * @param options.attribute.ISC.content=[]] {array} ISC内容 + * @param {object} options.attribute.isc={} isc + * @param options.attribute.isc.content=[]] {array} ISC内容 * @param {object} options.attribute.goods={} 物资 * @param options.attribute.goods.content=[]] {array} 物资内容 * @param options.attribute.goods.content[].ID {string} ID @@ -108,8 +104,6 @@ class BillboardObject extends Base { *@param _Dialog {object} 弹框事件 *@param _Dialog.confirmCallBack {function} 弹框确认时的回调 - *@param _Dialog.instructSubmit(id,name,instruct) {function} 提交指令(ID, 名称,指令内容) - *@param _Dialog.operatingPointSubmit(id,name,operatingPoint) {function} 设置操作点(ID, 名称,操作点内容) * */ constructor(sdk, options = {}, _Dialog = {}) { super(sdk, options) @@ -124,7 +118,7 @@ class BillboardObject extends Base { this.options.heightMode = options.heightMode || options.heightMode == 0 ? options.heightMode : 3 this.options.billboard = options.billboard = options.billboard || {} - this.options.billboard.isSelect = options.billboard.isSelect || false + // this.options.billboard.isSelect = options.billboard.isSelect || false this.options.billboard.show = options.billboard.show || options.billboard.show === false ? options.billboard.show @@ -148,17 +142,16 @@ class BillboardObject extends Base { this.options.label.fontFamily = options.label.fontFamily || 0 this.options.label.fontSize = options.label.fontSize || 39 this.options.label.color = options.label.color || '#00ffff' - this.options.positions = options.positions = options.positions || {} - this.options.positions.lng = Number( - Number(options.positions.lng || 0).toFixed(8) + this.options.position = options.position = options.position || {} + this.options.position.lng = Number( + Number(options.position.lng || 0).toFixed(8) ) - this.options.positions.lat = Number( - Number(options.positions.lat || 0).toFixed(8) + this.options.position.lat = Number( + Number(options.position.lat || 0).toFixed(8) ) - this.options.positions.alt = Number( - Number(options.positions.alt || 0).toFixed(2) + this.options.position.alt = Number( + Number(options.position.alt || 0).toFixed(2) ) - this.#_billboardHeight = this.options.positions.alt // this.options.diffuseShow = options.diffuseShow || false // this.options.diffuseRadius = (options.diffuseRadius || options.diffuseRadius === 0) ? options.diffuseRadius : 10 // this.options.diffuseDuration = (options.diffuseDuration || options.diffuseDuration === 0) ? options.diffuseDuration : 2000 @@ -167,8 +160,6 @@ class BillboardObject extends Base { // this.options.scanRadius = (options.scanRadius || options.scanRadius === 0) ? options.scanRadius : 10 // this.options.scanDuration = (options.scanDuration || options.scanDuration === 0) ? options.scanDuration : 2000 // this.options.scanColor = options.scanColor || "#FF0000" - this.options.instruct = options.instruct || '' - this.options.operatingPoint = options.operatingPoint || '' this.options.attribute = options.attribute || {} this.options.attribute.link = this.options.attribute.link || {} this.options.attribute.link.content = @@ -178,26 +169,24 @@ class BillboardObject extends Base { this.options.attribute.camera = this.options.attribute.camera || {} this.options.attribute.camera.content = this.options.attribute.camera.content || [] - this.options.attribute.ISC = this.options.attribute.ISC || {} - this.options.attribute.ISC.content = - this.options.attribute.ISC.content || [] + this.options.attribute.isc = this.options.attribute.isc || {} + this.options.attribute.isc.content = + this.options.attribute.isc.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' - this.options.coordinate = options.coordinate || '' - this.options.attributeBoxState = options.attributeBoxState || false + // this.options.coordinate = options.coordinate || '' this.operate = {} this._elms = {} this.previous = { - positions: { ...this.options.positions } - } - this.options.attributePos = options.attributePos || { - x: 60, - y: 60, - width: 200, - height: 120 + position: { ...this.options.position } } + // this.options.attributePos = options.attributePos || { + // x: 60, + // y: 60, + // width: 200, + // height: 120 + // } this.entity this._proj = this.sdk.proj @@ -229,123 +218,12 @@ class BillboardObject extends Base { // } - - this.#_destroyMouseEvent = () => { - this.attributeElm && (this.attributeElm.style.pointerEvents = 'unset') - if(this.sdk && this.sdk.viewer && this.sdk.viewer._element) { - this.sdk.viewer._element.onmousemove = null - } - document.removeEventListener('mouseup', this.#_destroyMouseEvent) - document.removeEventListener('mouseleave', this.#_destroyMouseEvent) - } - - this.#_postRenderEvent = () => { - let siteInfoPosition = Cesium.Cartesian3.fromDegrees( - this.options.positions.lng, - this.options.positions.lat, - this.#_billboardHeight - ) - if (this.attributeElm && this.entity) { - let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates( - siteInfoPosition - ) - let pixelOffset = this.entity.label.pixelOffset.getValue() - if (winpos) { - let scale = getCurrentBillboardScale(this.entity, this.sdk.viewer.scene) - let height = ((this.entity.billboard.height.getValue() * (this.options.billboard.scale || 0)) + this.options.label.fontSize) * (1 - (scale * scale)) - let flag = false - let lineElm = this.attributeElm.getElementsByClassName('billboard-attribute-box-line')[0] - let leftTopElm = this.attributeElm.getElementsByClassName('left-top')[0] - let rightTopElm = this.attributeElm.getElementsByClassName('right-top')[0] - this.attributeElm.style.left = (winpos.x + this.options.attributePos.x).toFixed(0) + 'px' - this.attributeElm.style.top = (winpos.y + pixelOffset.y - (this.options.label.show ? (this.options.label.fontSize / 2) : -(this.options.label.fontSize / 2)) - this.attributeElm.offsetHeight - this.options.attributePos.y + height).toFixed(0) + 'px' - this.attributeElm.style.width = this.options.attributePos.width + 'px' - this.attributeElm.style.height = this.options.attributePos.height + 'px' - lineElm.style.zIndex = '-1' - if (this.options.attributePos.x < -this.options.attributePos.width / 2) { - flag = true - lineElm.style.left = 'unset' - lineElm.style.right = '0' - leftTopElm.style.display = 'block' - rightTopElm.style.display = 'none' - } - else { - lineElm.style.left = '0' - lineElm.style.right = 'unset' - leftTopElm.style.display = 'none' - rightTopElm.style.display = 'block' - } - - let lineLength - let lineAngleRad - let lineAngle - let x - let y - if (flag) { - x = this.attributeElm.offsetWidth + this.options.attributePos.x - y = this.options.attributePos.y ? this.options.attributePos.y : 0 - } - else { - x = this.options.attributePos.x - y = this.options.attributePos.y ? this.options.attributePos.y : 0 - } - lineLength = Math.sqrt((x * x) + (y * y)).toFixed(2); - lineAngleRad = Math.atan(x / y); - lineAngle = parseFloat((lineAngleRad * 180 / Math.PI).toFixed(2)); - if (this.options.attributePos.y < 0) { - lineAngle = lineAngle + 180 - } - // if(this.options.attributePos.y<-this.options.attributePos.height/2) { - // lineElm.style.bottom = 'unset' - // lineElm.style.top = '0' - // } - // else { - // lineElm.style.bottom = -lineLength + 'px' - // lineElm.style.top = 'unset' - // } - lineElm.style.height = lineLength + 'px' - lineElm.style.transform = 'rotate(' + lineAngle + 'deg)' - } - } - } - - function getCurrentBillboardScale(entity, scene) { - // 获取相机到Billboard的距离 - const distance = Cesium.Cartesian3.distance( - scene.camera.positionWC, - entity.position.getValue() - ); - // 获取缩放距离配置 - const scaleByDistance = entity.billboard.scaleByDistance ? entity.billboard.scaleByDistance.getValue() : undefined; - - if (!scaleByDistance) { - // 如果没有设置距离缩放,则使用基础缩放值 - return 1.0; - } - - // 解析缩放距离参数 [near, nearScale, far, farScale] - const { near, nearValue, far, farValue } = scaleByDistance; - if (distance <= near) { - return nearValue; - } else if (distance >= far) { - return farValue; - } else { - // 计算中间距离的缩放值(线性插值) - const t = (distance - near) / (far - near); - return Cesium.Math.lerp(nearValue, farValue, t); - } - } - - this.sdk.addIncetance(this.options.id, this) BillboardObject.create(this) this.picking = true this.Dialog = _Dialog this._EventBinding = new EventBinding() - // this.Dialog.instructSubmit = () => { - // alert(6) - // } } get type() { @@ -356,7 +234,7 @@ class BillboardObject extends Base { let canvas let billboardH = 36 let heightMode - let positions = that.options.positions + let position = that.options.position that.originalOptions = that.deepCopyObj(that.options) let isGlf = false let superGif @@ -395,7 +273,6 @@ class BillboardObject extends Base { that.entity.billboard.imgHeight = 0 that.entity.billboard.image = canvas addCluster(that.sdk, that.entity) - that.attributeBoxState && (that.attributeBoxState = true) } return } @@ -420,7 +297,6 @@ class BillboardObject extends Base { return img }, false) addCluster(that.sdk, that.entity) - that.attributeBoxState && (that.attributeBoxState = true) } }) } @@ -452,7 +328,6 @@ class BillboardObject extends Base { that.entity.billboard.imgHeight = height that.entity.billboard.image = canvas addCluster(that.sdk, that.entity) - that.attributeBoxState && (that.attributeBoxState = true) } } image.onerror = function (err) { @@ -464,7 +339,6 @@ class BillboardObject extends Base { that.entity.billboard.imgHeight = 0 that.entity.billboard.image = canvas addCluster(that.sdk, that.entity) - that.attributeBoxState && (that.attributeBoxState = true) } }; } @@ -473,9 +347,9 @@ class BillboardObject extends Base { show: that.options.show, id: that.options.id, position: Cesium.Cartesian3.fromDegrees( - positions.lng, - positions.lat, - positions.alt + position.lng, + position.lat, + position.alt ), billboard: { image: isGlf ? new Cesium.CallbackProperty(() => { @@ -536,9 +410,9 @@ class BillboardObject extends Base { that.entity.billboard.imgWidth = 31 that.entity.billboard.imgHeight = 36 that.entity.position = Cesium.Cartesian3.fromDegrees( - positions.lng, - positions.lat, - positions.alt + position.lng, + position.lat, + position.alt ) if (that.options.heightMode == 3) { that.updateHeight() @@ -627,30 +501,9 @@ class BillboardObject extends Base { } if (!this.showView || this.showView == 3) { this.entity && (this.entity.show = this.options.show) - if (this.attributeBoxState && this.options.show) { - this.attributeBoxState = this.options.show - } - else { - // 关闭属性框 - document.addEventListener('mouseup', this.#_destroyMouseEvent); - document.addEventListener('mouseleave', this.#_destroyMouseEvent); - if (this.attributeElm) { - this.sdk.viewer._element.removeChild(this.attributeElm) - this.attributeElm = null - } - this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) - } } else { this.entity && (this.entity.show = false) - // 关闭属性框 - document.addEventListener('mouseup', this.#_destroyMouseEvent); - document.addEventListener('mouseleave', this.#_destroyMouseEvent); - if (this.attributeElm) { - this.sdk.viewer._element.removeChild(this.attributeElm) - this.attributeElm = null - } - this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) } syncData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id) @@ -686,81 +539,37 @@ class BillboardObject extends Base { this.options.heightMode = v || v == 0 ? v : 3 let heightMode let heightModeName = '' - let altBoxElm - if ( - this._DialogObject && - this._DialogObject._element && - this._DialogObject._element.content - ) { - altBoxElm = this._DialogObject._element.content.getElementsByClassName( - 'alt-box' - )[0] - } switch (this.options.heightMode) { case '0': case 0: - altBoxElm && - (altBoxElm.className = 'input-number input-number-unit-1 alt-box') - this._elms.height && (this._elms.height.style.display = 'flex') heightMode = Cesium.HeightReference.NONE - heightModeName = '海拔高度' break case '1': case 1: - altBoxElm && - (altBoxElm.className = 'input-number input-number-unit-1 alt-box') - this._elms.height && (this._elms.height.style.display = 'flex') heightMode = Cesium.HeightReference.NONE - heightModeName = '相对地表' break case '2': case 2: - altBoxElm && - (altBoxElm.className = - 'input-number input-number-unit-1 alt-box disabled') - heightModeName = '依附地表' - altBoxElm && - (altBoxElm.className = - 'input-number input-number-unit-1 alt-box disabled') - heightModeName = '依附地表' heightMode = Cesium.HeightReference.CLAMP_TO_GROUND - this._elms.height && (this._elms.height.style.display = 'none') break case '3': case 3: - altBoxElm && - (altBoxElm.className = - 'input-number input-number-unit-1 alt-box disabled') - this._elms.height && (this._elms.height.style.display = 'none') heightMode = Cesium.HeightReference.NONE - heightModeName = '依附模型' + let objectsToExclude = [] + for (let [key, value] of this.sdk.entityMap) { + if (value.type === 'RadarScanStereoscopic' && value.entity) { + objectsToExclude.push(value.entity) + } + } + this.getClampToHeight(this.options.position, objectsToExclude).then(h => { + this.alt = Number(h.toFixed(2)) + }) break } if (this.entity) { this.entity.billboard.heightReference = heightMode this.entity.label.heightReference = heightMode - if(heightMode == Cesium.HeightReference.CLAMP_TO_GROUND) { - if (this.sdk.viewer.scene.terrainProvider.availability) { - Cesium.sampleTerrainMostDetailed( - this.sdk.viewer.scene.terrainProvider, - [ - Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat - ) - ] - ).then(position => { - this.#_billboardHeight = position[0].height - }) - } else { - this.#_billboardHeight = 0 - } - } - else { - this.#_billboardHeight = this.options.positions.alt - } } - this._elms.heightMode && (this._elms.heightMode.value = heightModeName) } get labelText() { @@ -777,10 +586,10 @@ class BillboardObject extends Base { } get lng() { - return this.options.positions.lng + return this.options.position.lng } set lng(v) { - this.options.positions.lng = Number(Number(v).toFixed(8)) + this.options.position.lng = Number(Number(v).toFixed(8)) // this.scan && (this.scan.lng = v) // this.diffuse && (this.diffuse.lng = v) this.renewPoint() @@ -793,10 +602,10 @@ class BillboardObject extends Base { } get lat() { - return this.options.positions.lat + return this.options.position.lat } set lat(v) { - this.options.positions.lat = Number(Number(v).toFixed(8)) + this.options.position.lat = Number(Number(v).toFixed(8)) // this.scan && (this.scan.lat = v) // this.diffuse && (this.diffuse.lat = v) this.renewPoint() @@ -809,64 +618,14 @@ class BillboardObject extends Base { } get alt() { - return this.options.positions.alt + return this.options.position.alt } set alt(v) { - this.options.positions.alt = Number(Number(v).toFixed(2)) - this.#_billboardHeight = this.options.positions.alt + this.options.position.alt = Number(Number(v).toFixed(2)) // this.scan && (this.scan.alt = v) // this.diffuse && (this.diffuse.alt = v) this.renewPoint() this.coordinate = this.options.coordinate - this._elms.alt && - this._elms.alt.forEach(item => { - item.value = this.options.positions.alt - }) - - if (this._elms.height) { - let heightElm = this._elms.height.getElementsByClassName('height')[0] - if (heightElm) { - switch (this._elms.heightMode.value) { - case '海拔高度': - heightElm.value = this.options.positions.alt - break - // case '相对高度': - // this.getClampToHeight(this.options.positions).then(h => { - // heightElm.value = Number( - // (this.options.positions.alt - h).toFixed(2) - // ) - // }) - // break - case '相对地表': - if (this.sdk.viewer.scene.terrainProvider.availability) { - Cesium.sampleTerrainMostDetailed( - this.sdk.viewer.scene.terrainProvider, - [ - Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat - ) - ] - ).then(position => { - heightElm.value = Number( - (this.options.positions.alt - position[0].height).toFixed(2) - ) - }) - } else { - heightElm.value = Number( - Number(this.options.positions.alt).toFixed(2) - ) - } - break - case '依附地表': - case '依附地表': - break - case '依附模型': - this.updateHeight() - break - } - } - } } get near() { @@ -1314,51 +1073,6 @@ class BillboardObject extends Base { // } // } - get instruct() { - return this.options.instruct - } - set instruct(v) { - this.options.instruct = v - this._elms.instruct && - this._elms.instruct.forEach(item => { - item.value = v - }) - } - - get operatingPoint() { - return this.options.operatingPoint - } - set operatingPoint(v) { - this.options.operatingPoint = v - this._elms.operatingPoint && - this._elms.operatingPoint.forEach(item => { - item.value = v - }) - } - - 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 @@ -1533,11 +1247,11 @@ class BillboardObject extends Base { } get attributeISC() { - return this.options.attribute.ISC.content + return this.options.attribute.isc.content } set attributeISC(v) { - this.options.attribute.ISC.content = v + this.options.attribute.isc.content = v } get attributeVr() { @@ -1732,13 +1446,14 @@ class BillboardObject extends Base { return this.options.coordinate } set coordinate(v) { + return this.options.coordinate = v let position = this._proj.convert( [ { - x: this.options.positions.lng, - y: this.options.positions.lat, - z: this.options.positions.alt + x: this.options.position.lng, + y: this.options.position.lat, + z: this.options.position.alt } ], 'EPSG:4326', @@ -1771,6 +1486,7 @@ class BillboardObject extends Base { * @param state=false {boolean} 状态: true打开, false关闭 */ async edit(state = false) { + return let _this = this this.originalOptions = this.deepCopyObj(this.options) @@ -1838,9 +1554,8 @@ class BillboardObject extends Base { let contentElm = document.createElement('div') contentElm.innerHTML = html(this) this._DialogObject.contentAppChild(contentElm) - this.attributeType = this.options.attributeType this.attributeCamera = this.options.attribute.camera.content - this.attributeISC = this.options.attribute.ISC.content + this.attributeISC = this.options.attribute.isc.content // let coordinateElm = contentElm.getElementsByClassName('coordinate-select')[0] // let option = '' @@ -1925,11 +1640,6 @@ class BillboardObject extends Base { let row = this._DialogObject._element.content.getElementsByClassName('attribute')[0].getElementsByClassName('row')[0] row.appendChild(col) - let boxSwitch = col.getElementsByClassName('btn-switch')[0] - boxSwitch.checked = this.attributeBoxState - boxSwitch.addEventListener('change', (e) => { - this.attributeBoxState = boxSwitch.checked - }) let tagData = this.attributeSelect let attributeElm = this._DialogObject._element.content.getElementsByClassName( 'attribute-select-box' @@ -2037,8 +1747,8 @@ class BillboardObject extends Base { this.sdk.viewer.scene.terrainProvider, [ Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat + this.options.position.lng, + this.options.position.lat ) ] ).then(position => { @@ -2060,7 +1770,7 @@ class BillboardObject extends Base { objectsToExclude.push(value.entity) } } - this.getClampToHeight(this.options.positions, objectsToExclude).then(h => { + this.getClampToHeight(this.options.position, objectsToExclude).then(h => { this.alt = Number(h.toFixed(2)) heightElm.value = this.alt }) @@ -2103,8 +1813,8 @@ class BillboardObject extends Base { this.sdk.viewer.scene.terrainProvider, [ Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat + this.options.position.lng, + this.options.position.lat ) ] ).then(position => { @@ -2130,7 +1840,7 @@ class BillboardObject extends Base { objectsToExclude.push(value.entity) } } - this.getClampToHeight(this.options.positions, objectsToExclude).then(h => { + this.getClampToHeight(this.options.position, objectsToExclude).then(h => { this.alt = Number(h.toFixed(2)) }) this.heightMode = 3 @@ -2145,7 +1855,7 @@ class BillboardObject extends Base { switch (heightMode) { case 0: case '0': - this.options.positions.alt = Number( + this.options.position.alt = Number( Number(heightElm.value).toFixed(2) ) break @@ -2156,8 +1866,8 @@ class BillboardObject extends Base { this.sdk.viewer.scene.terrainProvider, [ Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat + this.options.position.lng, + this.options.position.lat ) ] ).then(position => { @@ -2177,7 +1887,7 @@ class BillboardObject extends Base { this.coordinate = this.options.coordinate this._elms.alt && this._elms.alt.forEach(item => { - item.value = this.options.positions.alt + item.value = this.options.position.alt }) }) this._elms.height = heightBoxElm @@ -2338,9 +2048,9 @@ class BillboardObject extends Base { if (this.entity) { this.entity.position = Cesium.Cartesian3.fromDegrees( - this.options.positions.lng, - this.options.positions.lat, - this.options.positions.alt + this.options.position.lng, + this.options.position.lat, + this.options.position.alt ) if (this.options.scaleByDistance) { this.entity.billboard.scaleByDistance = new Cesium.NearFarScalar( @@ -2423,25 +2133,14 @@ class BillboardObject extends Base { this.labelShow = this.originalOptions.label.show this.labelFontSize = this.originalOptions.label.fontSize this.labelColor = this.originalOptions.label.color - this.lng = this.originalOptions.positions.lng - this.lat = this.originalOptions.positions.lat - this.alt = this.originalOptions.positions.alt - // this.diffuseShow = this.originalOptions.diffuseShow - // this.diffuseRadius = this.originalOptions.diffuseRadius - // this.diffuseDuration = this.originalOptions.diffuseDuration - // this.diffuseColor = this.originalOptions.diffuseColor - // this.scanShow = this.originalOptions.scanShow - // this.scanRadius = this.originalOptions.scanRadius - // this.scanDuration = this.originalOptions.scanDuration - // this.scanColor = this.originalOptions.scanColor - this.instruct = this.originalOptions.instruct - this.operatingPoint = this.originalOptions.operatingPoint + this.lng = this.originalOptions.position.lng + this.lat = this.originalOptions.position.lat + this.alt = this.originalOptions.position.alt 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.attributeISC = this.options.attribute.ISC.content - this.attributeBoxState = this.options.attributeBoxState + this.attributeISC = this.options.attribute.isc.content this.cameraSelect && this.cameraSelect() this.goodsSelect && this.goodsSelect() } @@ -2449,7 +2148,6 @@ class BillboardObject extends Base { async remove() { await remove_entity_from_cluster(this.sdk.viewer, this.entity) this.entity = null - this.attributeBoxState = false if (!this.sdk.viewer || !this.sdk.viewer.entities) { return } @@ -2481,98 +2179,6 @@ class BillboardObject extends Base { this.Dialog.clickChangeDefaultImage && this.Dialog.clickChangeDefaultImage() } - instructSubmit() { - this.Dialog.instructSubmit && - this.Dialog.instructSubmit( - this.options.id, - this.options.label.text, - this.instruct - ) - this.originalOptions.instruct = this.instruct - } - - operatingPointSubmit() { - this.Dialog.operatingPointSubmit && - this.Dialog.operatingPointSubmit( - this.options.id, - this.options.label.text, - this.operatingPoint - ) - this.originalOptions.operatingPoint = this.operatingPoint - } - - _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 - } - - /** - * 打开富文本框 - */ - 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 - } - } - async updateHeight() { if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.scene) { return @@ -2580,13 +2186,13 @@ class BillboardObject extends Base { let height let height2 let point1 = new Cesium.Cartesian3.fromDegrees( - this.options.positions.lng, - this.options.positions.lat, + this.options.position.lng, + this.options.position.lat, 0 ) let point2 = new Cesium.Cartesian3.fromDegrees( - this.options.positions.lng, - this.options.positions.lat, + this.options.position.lng, + this.options.position.lat, 10000000000000 ) @@ -2625,8 +2231,8 @@ class BillboardObject extends Base { this.sdk.viewer.terrainProvider, [ Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat + this.options.position.lng, + this.options.position.lat ) ] ) @@ -2639,55 +2245,10 @@ class BillboardObject extends Base { height = height2 } if (height !== undefined) { - this.options.positions.alt = Number(Number(height).toFixed(2)) - this.#_billboardHeight = this.options.positions.alt - this._elms.alt && - this._elms.alt.forEach(item => { - item.value = this.options.positions.alt - }) - // this.scan && (this.scan.alt = v) - // this.diffuse && (this.diffuse.alt = v) + this.options.position.alt = Number(Number(height).toFixed(2)) this.renewPoint() this.coordinate = this.options.coordinate - - if (this._elms.height) { - let heightElm = this._elms.height.getElementsByClassName('height')[0] - if (heightElm) { - switch (this._elms.heightMode.value) { - case '海拔高度': - heightElm.value = this.options.positions.alt - this.#_billboardHeight = this.options.positions.alt - break - case '相对地表': - if (this.sdk.viewer.scene.terrainProvider.availability) { - Cesium.sampleTerrainMostDetailed( - this.sdk.viewer.scene.terrainProvider, - [ - Cesium.Cartographic.fromDegrees( - this.options.positions.lng, - this.options.positions.lat - ) - ] - ).then(position => { - heightElm.value = Number( - (this.options.positions.alt - position[0].height).toFixed(2) - ) - this.#_billboardHeight = this.options.positions.alt - }) - } else { - heightElm.value = this.options.positions.alt - this.#_billboardHeight = this.options.positions.alt - } - break - case '依附地表': - break - case '依附模型': - heightElm.value = this.options.positions.alt - this.#_billboardHeight = this.options.positions.alt - break - } - } - } + return true } } @@ -2721,8 +2282,8 @@ class BillboardObject extends Base { let position = { lng: 0, lat: 0 } if (this.options.position) { position = { ...this.options.position } - } else if (this.options.positions) { - position = { ...this.options.positions } + } else if (this.options.position) { + position = { ...this.options.position } } else if (this.options.center) { position = { ...this.options.center } } else if (this.options.start) { @@ -2763,12 +2324,12 @@ class BillboardObject extends Base { objectsToExclude.push(value.entity) } } - let height = await this.getClampToHeight(this.options.positions, objectsToExclude) + let height = await this.getClampToHeight(this.options.position, objectsToExclude) this.sdk.viewer.camera.flyTo({ orientation: options.orientation, destination: Cesium.Cartesian3.fromDegrees( - this.options.positions.lng, - this.options.positions.lat, + this.options.position.lng, + this.options.position.lat, height + (options.height || 500) ) }) @@ -2776,9 +2337,9 @@ class BillboardObject extends Base { } setPosition(v) { - this.options.positions.lng = v.position.lng - this.options.positions.lat = v.position.lat - this.options.positions.alt = v.position.alt + this.options.position.lng = v.position.lng + this.options.position.lat = v.position.lat + this.options.position.alt = v.position.alt this.renewPoint() } @@ -2800,7 +2361,7 @@ class BillboardObject extends Base { this.tip && this.tip.destroy() this.tip = new MouseTip('点击鼠标左键确认,右键取消', this.sdk) this.previous = { - positions: { ...this.options.positions } + position: { ...this.options.position } } let moveEvent = (movement, cartesian) => { this.entity.position = new Cesium.CallbackProperty(function () { @@ -2819,7 +2380,7 @@ class BillboardObject extends Base { this.lat = positions.lat this.alt = positions.alt this.previous = { - positions: { ...this.options.positions } + position: { ...this.options.position } } this.event.mouse_move(() => { }) this.event.mouse_left(() => { }) @@ -2829,6 +2390,10 @@ class BillboardObject extends Base { this.entity.position = new Cesium.CallbackProperty(function () { return cartesian }, false) + if(this.#_positionEditingCallback) { + this.#_positionEditingCallback() + this.#_positionEditingCallback = null + } this.positionEditing = false } this.event.mouse_move(moveEvent) @@ -2856,6 +2421,7 @@ class BillboardObject extends Base { }) }) } else { + this.#_positionEditingCallback = null this.picking = true if (this.event) { this.event.mouse_move(() => { }) @@ -2867,9 +2433,9 @@ class BillboardObject extends Base { this.event = null } this.tip && this.tip.destroy() - this.lng = this.previous.positions.lng - this.lat = this.previous.positions.lat - this.alt = this.previous.positions.alt + this.lng = this.previous.position.lng + this.lat = this.previous.position.lat + this.alt = this.previous.position.alt this.renewPoint() } } @@ -2878,13 +2444,18 @@ class BillboardObject extends Base { return this.operate.positionEditing } + openPositionEditing(cd) { + this.positionEditing = true + this.#_positionEditingCallback = cd + } + setDIV(options = { domid: '', x: 10, y: 10 }) { options.x = options.x || options.x === 0 ? options.x : 10 options.y = options.y || options.y === 0 ? options.y : 10 let siteInfoDom = document.getElementById(options.domid) let siteInfoPosition = Cesium.Cartesian3.fromDegrees( - this.options.positions.lng, - this.options.positions.lat + this.options.position.lng, + this.options.position.lat ) this.sdk.viewer.scene.postRender.addEventListener(percentage => { @@ -2916,8 +2487,8 @@ class BillboardObject extends Base { let position = { lng: 0, lat: 0 } let relativePosition = { ...cameraPosition84 } - if (this.options.positions) { - position = { ...this.options.positions } + if (this.options.position) { + position = { ...this.options.position } } else { if (this.options.hasOwnProperty('lng')) { position.lng = this.options.lng @@ -2957,219 +2528,6 @@ class BillboardObject extends Base { (this.originalOptions.customView = this.options.customView) } } - - get attributeBoxState() { - return this.options.attributeBoxState - } - - set attributeBoxState(state) { - state = state ? true : false - this.options.attributeBoxState = state - document.addEventListener('mouseup', this.#_destroyMouseEvent); - document.addEventListener('mouseleave', this.#_destroyMouseEvent); - if (this.attributeElm) { - this.sdk.viewer._element.removeChild(this.attributeElm) - this.attributeElm = null - } - this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent) - if (state && this.sdk && this.sdk.viewer && this.sdk.viewer._element && this.show) { - let attributeElm = document.createElement('div') - this.attributeElm = attributeElm - attributeElm.className = 'billboard-attribute-box' - attributeElm.style.top = '0px' - attributeElm.style.left = '0px' - attributeElm.style.width = 0 - attributeElm.style.height = 0 - if(getState()) { - attributeElm.style.display = 'none' - } - // attributeElm.innerHTML = this.options.richTextContent - this.sdk.viewer._element.appendChild(attributeElm) - let linkHtml = '' - let goodsHtml = '' - let richTextHtml = '' - for (let i = 0; i < this.options.attribute.link.content.length; i++) { - linkHtml += `` - } - if (this.options.attribute.goods && this.options.attribute.goods.content && this.options.attribute.goods.content.length > 0) { - goodsHtml += ` -
-
-
-
序号
-
名称
-
数量
-
-
-
- ` - for (let i = 0; i < this.options.attribute.goods.content.length; i++) { - goodsHtml += `
-
${i + 1}
-
${this.options.attribute.goods.content[i].name}
-
${this.options.attribute.goods.content[i].cnt}
-
` - } - goodsHtml += `
` - } - if (this.options.richTextContent) { - richTextHtml = ` - ${this.options.richTextContent} - ` - } - - let boxHtml = ` - - - ` - - if (!linkHtml && !goodsHtml && !richTextHtml) { - boxHtml = boxHtml + '

暂无属性信息

' - } - else { - boxHtml = boxHtml + ` - - ${richTextHtml} - ${goodsHtml} - ${linkHtml} - -
` - } - - attributeElm.innerHTML = boxHtml - - if (attributeElm.getElementsByClassName('tabs')[0]) { - let tabsElm = new cy_tabs(attributeElm.getElementsByClassName('tabs')[0], undefined, this.sdk) - } - - let imgElm = attributeElm.getElementsByTagName('img') - for (let i = 0; i < imgElm.length; i++) { - if (!imgElm[i].style.width) { - imgElm[i].style.width = '100%' - } - } - - this.sdk.viewer.scene.postRender.addEventListener(this.#_postRenderEvent) - let leftOnmousedown = (e) => { - if (this.options.attributePos.width < 200) { - this.options.attributePos.width = 200 - } - if (this.options.attributePos.height < 120) { - this.options.attributePos.height = 120 - } - let x = e.x - let y = e.y - let width = this.options.attributePos.width - let height = this.options.attributePos.height - let positionx = this.options.attributePos.x - this.sdk.viewer._element.onmousemove = (e2) => { - this.options.attributePos.width = width + (x - e2.x) - this.options.attributePos.height = height + (y - e2.y) - if (this.options.attributePos.width < 200) { - this.options.attributePos.width = 200 - } - else { - this.options.attributePos.x = positionx - (x - e2.x) - } - if (this.options.attributePos.height < 120) { - this.options.attributePos.height = 120 - } - // this.options.attributePos.y = positiony + (y - e2.y) - } - document.addEventListener('mouseup', this.#_destroyMouseEvent); - document.addEventListener('mouseleave', this.#_destroyMouseEvent); - } - let rightOnmousedown = (e) => { - let x = e.x - let y = e.y - if (this.options.attributePos.width < 200) { - this.options.attributePos.width = 200 - } - if (this.options.attributePos.height < 120) { - this.options.attributePos.height = 120 - } - let width = this.options.attributePos.width - let height = this.options.attributePos.height - this.sdk.viewer._element.onmousemove = (e2) => { - this.options.attributePos.width = width + (e2.x - x) - this.options.attributePos.height = height + (y - e2.y) - } - document.addEventListener('mouseup', this.#_destroyMouseEvent); - document.addEventListener('mouseleave', this.#_destroyMouseEvent); - } - // leftTopElm.onmousedown = (e) => { - // console.log(1111111111) - // if (this.options.attributePos.width < 200) { - // this.options.attributePos.width = 200 - // } - // if (this.options.attributePos.height < 120) { - // this.options.attributePos.height = 120 - // } - // let x = e.x - // let y = e.y - // let width = this.options.attributePos.width - // let height = this.options.attributePos.height - // let positionx = this.options.attributePos.x - // this.sdk.viewer._element.onmousemove = (e2) => { - // this.options.attributePos.width = width + (x - e2.x) - // this.options.attributePos.height = height + (y - e2.y) - // if (this.options.attributePos.width < 200) { - // this.options.attributePos.width = 200 - // } - // else { - // this.options.attributePos.x = positionx - (x - e2.x) - // } - // if (this.options.attributePos.height < 120) { - // this.options.attributePos.height = 120 - // } - // // this.options.attributePos.y = positiony + (y - e2.y) - // } - // document.addEventListener('mouseup', this.#_destroyMouseEvent); - // document.addEventListener('mouseleave', this.#_destroyMouseEvent); - // } - // rightTopElm.onmousedown = (e) => { - // let x = e.x - // let y = e.y - // if (this.options.attributePos.width < 200) { - // this.options.attributePos.width = 200 - // } - // if (this.options.attributePos.height < 120) { - // this.options.attributePos.height = 120 - // } - // let width = this.options.attributePos.width - // let height = this.options.attributePos.height - // this.sdk.viewer._element.onmousemove = (e2) => { - // this.options.attributePos.width = width + (e2.x - x) - // this.options.attributePos.height = height + (y - e2.y) - // } - // document.addEventListener('mouseup', this.#_destroyMouseEvent); - // document.addEventListener('mouseleave', this.#_destroyMouseEvent); - // } - - attributeElm.onmousedown = (e) => { - attributeElm.style.pointerEvents = 'none' - if (e.target.className.indexOf('left-top') != -1) { - leftOnmousedown(e) - } - else if (e.target.className.indexOf('right-top') != -1) { - rightOnmousedown(e) - } - else { - let x = e.x - let y = e.y - let oldX = this.options.attributePos.x - let oldXY = this.options.attributePos.y - let height = this.options.attributePos.height - this.sdk.viewer._element.onmousemove = (e2) => { - this.options.attributePos.x = oldX + (e2.x - x) - this.options.attributePos.y = oldXY - (e2.y - y) - } - document.addEventListener('mouseup', this.#_destroyMouseEvent); - document.addEventListener('mouseleave', this.#_destroyMouseEvent); - } - } - } - } } export default BillboardObject diff --git a/src/Obj/Base/CurvelineObject/index.js b/src/Obj/Base/CurvelineObject/index.js index 04ddbb1..ecb5a46 100644 --- a/src/Obj/Base/CurvelineObject/index.js +++ b/src/Obj/Base/CurvelineObject/index.js @@ -81,20 +81,18 @@ class CurvelineObject extends Base { this.options.width = ((options.width || options.width === 0) ? options.width : 3) this.options.color = options.color || '#ff0000' this.options.type = options.type ? Number(options.type) : 0 - this.options['nose-to-tail'] = options['nose-to-tail'] || false + this.options.noseToTail = options.noseToTail || false this.options.extend = options.extend || false - this.options.rotate = options.rotate || true + this.options.rotate = (options.rotate || options.rotate === false) ? options.rotate : true this.options.space = options.space || 1 this.options.speed = options.speed || 10 - this.options.dashSize = options.dashSize || 0.03 - this.options['length-unit'] = options['length-unit'] || '米' - this.options['fit-length-unit'] = options['fit-length-unit'] || '米' - this.options['words-name'] = options['words-name'] || '空间长度' - this.options['extend-width'] = - options['extend-width'] || options['extend-width'] === 0 - ? options['extend-width'] + // this.options.dashSize = options.dashSize || 0.03 + this.options.wordsName = options.wordsName || 0 + this.options.extendWidth = + options.extendWidth || options.extendWidth === 0 + ? options.extendWidth : 10 - this.options['extend-color'] = options['extend-color'] || 'rgba(255,255,80,0.3)' + this.options.extendColor = options.extendColor || 'rgba(255,255,80,0.3)' this.options.show = options.show || options.show === false ? options.show : true this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 @@ -130,22 +128,26 @@ class CurvelineObject extends Base { ? options.label.far : 100000 } - this.options.instruct = options.instruct || '' - this.options.operatingPoint = options.operatingPoint || '' this.options.attribute = options.attribute || {} this.options.attribute.link = this.options.attribute.link || {} this.options.attribute.link.content = this.options.attribute.link.content || [] - this.options.attribute.camera = this.options.attribute.camera || {} - this.options.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' + // 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 || [] + + + delete this.options.attribute.camera + delete this.options.attribute.vr + delete this.options.attribute.goods + + this.operate = {} this.nodePoints = [] this.unitNum = 0 @@ -154,12 +156,6 @@ class CurvelineObject extends Base { if (!this.options.positions || this.options.positions.length < 2) { this._error = '线段最少需要两个坐标!' console.warn(this._error) - window.ELEMENT && - window.ELEMENT.Message({ - message: this._error, - type: 'warning', - duration: 1500 - }) } else { for (let i = 0; i < this.options.positions.length; i++) { @@ -216,17 +212,17 @@ class CurvelineObject extends Base { // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) } - get dashSize() { - return this.options.dashSize - } + // get dashSize() { + // return this.options.dashSize + // } - set dashSize(v) { - this.options.dashSize = v - let params = { ...this.options } - params.speed = this.inputSpeed - // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) - this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) - } + // set dashSize(v) { + // this.options.dashSize = v + // let params = { ...this.options } + // params.speed = this.inputSpeed + // // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) + // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) + // } get rotate() { return this.options.rotate @@ -234,7 +230,7 @@ class CurvelineObject extends Base { set rotate(v) { this.options.rotate = v - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() this._elms.rotate && this._elms.rotate.forEach(item => { item.checked = v @@ -256,74 +252,11 @@ class CurvelineObject extends Base { this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) } - get length() { - return this.options.length - } - - set length(v) { - this.options.length = v - //判断数值是否大于1000m - - this._elms.length && - this._elms.length.forEach(item => { - item.value = v - }) - } - - get fitLength() { - return this.options.fitLength - } - - set fitLength(v) { - this.options.fitLength = v - this._elms.fitLength && - this._elms.fitLength.forEach(item => { - item.value = v - }) - } - - get lengthUnit() { - return this.options['length-unit'] - } - set lengthUnit(v) { - this.unitNum++ - this.options['length-unit'] = v - this._elms.lengthUnit && - this._elms.lengthUnit.forEach(item => { - item.value = v - }) - if (this.options.lengthByMeter) { - if (this.unitNum > 2) { - switch (v) { - case '米': - this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter - - break - case '千米': - this.length = this.noseToTail ? (this.options.fitLengthByMeter / 1000).toFixed(5) : (this.options.lengthByMeter / 1000).toFixed(5) - - break - default: - this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter - - break - } - } else { - let length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter - this.lengthUnit = length > 1000 || length == 1000 ? '千米' : '米' - } - } - } - get wordsName() { - return this.options['words-name'] + return this.options.wordsName } set wordsName(v) { - this.options['words-name'] = v - this._elms.wordsName && - this._elms.wordsName.forEach(item => { - item.value = v - }) + this.options.wordsName = v let _this = this if (!this.noseToTail) { @@ -332,38 +265,38 @@ class CurvelineObject extends Base { 2, v ).then(res => { - _this.options.lengthByMeter = res - _this.lengthUnit = this.options['length-unit'] + _this.lengthByMeter = res + this.lengthChangeCallBack && this.lengthChangeCallBack() }) } else { let fromDegreesArray = this.renewPositions(this.options.positions) } } - get fitLengthUnit() { - return this.options['fit-length-unit'] - } - set fitLengthUnit(v) { - this.options['fit-length-unit'] = v - this._elms.fitLengthUnit && - this._elms.fitLengthUnit.forEach(item => { - item.value = v - }) - if (this.options.fitLengthByMeter) { - switch (v) { - case '米': - this.fitLength = this.options.fitLengthByMeter - break - case '千米': - this.fitLength = Number( - (this.options.fitLengthByMeter / 1000).toFixed(5) - ) - break - default: - this.fitLength = this.options.fitLengthByMeter - } - } - } + // get fitLengthUnit() { + // return this.options['fit-length-unit'] + // } + // set fitLengthUnit(v) { + // this.options['fit-length-unit'] = v + // this._elms.fitLengthUnit && + // this._elms.fitLengthUnit.forEach(item => { + // item.value = v + // }) + // if (this.options.fitLengthByMeter) { + // switch (v) { + // case '米': + // this.fitLength = this.options.fitLengthByMeter + // break + // case '千米': + // this.fitLength = Number( + // (this.options.fitLengthByMeter / 1000).toFixed(5) + // ) + // break + // default: + // this.fitLength = this.options.fitLengthByMeter + // } + // } + // } get lineWidth() { return this.options.width @@ -375,9 +308,13 @@ class CurvelineObject extends Base { this._elms.lineWidth.forEach(item => { item.value = this.options.width }) - this.entity && - this.entity.polyline && - (this.entity.polyline.width = this.options.width) + if (this.entity && this.entity.polyline) { + this.entity.polyline.width = this.entity.polyline.width + v - this.entity.polyline.oriWidth + this.entity.polyline.oriWidth = this.options.width + } + // this.entity && + // this.entity.polyline && + // (this.entity.polyline.width = this.options.width) && (this.entity.polyline.oriWidth = this.options.width) } get lineType() { @@ -499,12 +436,12 @@ class CurvelineObject extends Base { )) } get noseToTail() { - return this.options['nose-to-tail'] + return this.options.noseToTail } set noseToTail(v) { - this.options['nose-to-tail'] = v - CurvelineObject.closeNodeEdit(this) + this.options.noseToTail = v + this.closeNodeEdit() this._elms.noseToTail && this._elms.noseToTail.forEach(item => { item.checked = v @@ -516,7 +453,6 @@ class CurvelineObject extends Base { ) this.renewPolygon(fromDegreesArray) } - this.lengthUnit = this.options['length-unit'] // if (v) { // if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) { // let dom = document.getElementsByClassName('input-select-unit')[1] @@ -545,7 +481,7 @@ class CurvelineObject extends Base { this.positionEditing = false this.options.heightMode = (v || v == 0) ? v : 2 let heightModeName = '' - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() let ground = false let disabled = false let fromDegreesArray = this.renewPositions(this.options.positions) @@ -580,7 +516,7 @@ class CurvelineObject extends Base { // 2, // ground // ) - this.lengthUnit = this.lengthUnit + // this.lengthUnit = this.lengthUnit this._elms.heightMode && (this._elms.heightMode.value = heightModeName) this._elms.heightModeObject && (this._elms.heightModeObject.legp_searchActive( heightModeName @@ -625,7 +561,7 @@ class CurvelineObject extends Base { set extend(v) { this.options.extend = v - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() if (v) { this.heightMode = 2 } @@ -644,11 +580,11 @@ class CurvelineObject extends Base { } get extendWidth() { - return this.options['extend-width'] + return this.options.extendWidth } set extendWidth(v) { - this.options['extend-width'] = v + this.options.extendWidth = v this._elms.extendWidth && this._elms.extendWidth.forEach(item => { item.value = v @@ -658,10 +594,10 @@ class CurvelineObject extends Base { } get extendColor() { - return this.options['extend-color'] + return this.options.extendColor } set extendColor(v) { - this.options['extend-color'] = v + this.options.extendColor = v if (this._elms.extendColor) { this._elms.extendColor.forEach((item, i) => { let extendColorPicker = new YJColorPicker({ @@ -684,7 +620,7 @@ class CurvelineObject extends Base { this.entity && this.entity.polygon && (this.entity.polygon.material = Cesium.Color.fromCssColorString( - this.options['extend-color'] + this.options.extendColor )) } @@ -911,396 +847,185 @@ class CurvelineObject extends Base { }) } } + // get attributeCamera() { + // return this.options.attribute.camera.content + // } - get instruct() { - return this.options.instruct - } - set instruct(v) { - this.options.instruct = v - this._elms.instruct && - this._elms.instruct.forEach(item => { - item.value = v - }) - } + // set attributeCamera(v) { + // this.options.attribute.camera.content = v + // } - get operatingPoint() { - return this.options.operatingPoint - } - set operatingPoint(v) { - this.options.operatingPoint = v - this._elms.operatingPoint && - this._elms.operatingPoint.forEach(item => { - item.value = v - }) - } + // get attributeVr() { + // return this.options.attribute.vr.content + // } - get attributeType() { - return this.options.attributeType - } + // 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 = + // ` + //
+ //
` + + // this.options.attribute.vr.content[i].name + + // `
+ //
` + + // this.options.attribute.vr.content[i].url + + // `
+ //
+ // + // + //
+ //
` + // 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 = ` + //
+ // + //
+ //
+ // + //
+ //
+ // + // + //
` + // 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 + // }, - 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' - } - } - } + // 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 attributeLink() { - return this.options.attribute.link.content - } + // get attributeGoods() { + // return this.options.attribute.goods.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 = - ` -
-
` + - this.options.attribute.link.content[i].name + - `
-
` + - this.options.attribute.link.content[i].url + - `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 = - ` -
-
` + - this.options.attribute.vr.content[i].name + - `
-
` + - this.options.attribute.vr.content[i].url + - `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 - } + // set attributeGoods(v) { + // this.options.attribute.goods.content = v + // } static async createLabel(that) { let height @@ -1406,17 +1131,17 @@ class CurvelineObject extends Base { that.computeDistance( that.smoothHandle(positions), 2, - that.options['words-name'] + that.options.wordsName ).then(res => { - that.options.lengthByMeter = res - that.lengthUnit = that.options['length-unit'] + that.lengthByMeter = res + that.lengthChangeCallBack && that.lengthChangeCallBack() syncData(that.sdk, that.options.id) }) if (that.options.show) { setSplitDirection(0, that.options.id) } - // if (this.options['nose-to-tail']) { + // if (this.options.noseToTail) { // let array = [] // for (let i = 0; i < fromDegreesArray.length; i += 2) { // array.push({ lng: fromDegreesArray[i], lat: fromDegreesArray[i + 1] }) @@ -1561,6 +1286,7 @@ class CurvelineObject extends Base { * @param {boolean} state true打开,false关闭 */ async edit(state) { + return let _this = this this.originalOptions = this.deepCopyObj(this.options) if (this._DialogObject && this._DialogObject.close) { @@ -1619,7 +1345,7 @@ class CurvelineObject extends Base { this.positionEditing = false this.noseToTail = false this.heightMode = 0 - CurvelineObject.nodeEdit(this) + this.nodeEdit() } }) this._DialogObject._element.body.className = @@ -1743,9 +1469,9 @@ class CurvelineObject extends Base { setTimeout(() => { this.attributeLink = this.options.attribute.link.content - this.attributeVr = this.options.attribute.vr.content - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() + // this.attributeVr = this.options.attribute.vr.content + // this.cameraSelect && this.cameraSelect() + // this.goodsSelect && this.goodsSelect() let tagData = this.attributeSelect let attributeElm = this._DialogObject._element.content.getElementsByClassName( 'attribute-select-box' @@ -1800,7 +1526,7 @@ class CurvelineObject extends Base { .getElementsByClassName('input-select-unit')[0] .getElementsByTagName('input')[0] this._elms.wordsName = [nameDataLegpElm] - nameDataLegpElm.value = this.options['words-name'] + nameDataLegpElm.value = this.options.wordsName for (let i = 0; i < nameData.length; i++) { if (nameData[i].value === nameDataLegpElm.value) { nameDataLegpObject.legp_searchActive(nameData[i].value) @@ -1842,7 +1568,6 @@ class CurvelineObject extends Base { .getElementsByClassName('input-select-unit')[1] .getElementsByTagName('input')[0] this._elms.lengthUnit = [unitDataLegpElm] - unitDataLegpElm.value = this.options['length-unit'] for (let i = 0; i < unitData.length; i++) { if (unitData[i].value === unitDataLegpElm.value) { unitDataLegpObject.legp_searchActive(unitData[i].value) @@ -2120,7 +1845,7 @@ class CurvelineObject extends Base { ) this.positionEditing = false - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() }) } @@ -2183,7 +1908,7 @@ class CurvelineObject extends Base { lngBox.appendChild(lngInput) lngInput.focus() this.positionEditing = false - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() }) lngInput.addEventListener('blur', () => { lngInput.value = Number(this.options.positions[i].lng.toFixed(8)) @@ -2204,7 +1929,7 @@ class CurvelineObject extends Base { latBox.appendChild(latInput) latInput.focus() this.positionEditing = false - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() }) latInput.addEventListener('blur', () => { latInput.value = Number(this.options.positions[i].lat.toFixed(8)) @@ -2228,7 +1953,7 @@ class CurvelineObject extends Base { altBox.appendChild(altInput) altInput.focus() this.positionEditing = false - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() }) altInput.addEventListener('blur', () => { altInput.value = Number(this.options.positions[i].alt.toFixed(2)) @@ -2316,7 +2041,7 @@ class CurvelineObject extends Base { } // 更新坐标 - renewPositions(positionsArray) { + renewPositions(positionsArray, cd) { if (this._error) { return } @@ -2343,8 +2068,8 @@ class CurvelineObject extends Base { let newPositions let fromDegreesArray = [] if ( - this.options['nose-to-tail'] && - this.options['nose-to-tail'] !== 'false' + this.options.noseToTail && + this.options.noseToTail !== 'false' ) { newPositions = [...positions, positions[0]] } else { @@ -2380,8 +2105,8 @@ class CurvelineObject extends Base { if ( - (this.options['nose-to-tail'] && - this.options['nose-to-tail'] !== 'false') || + (this.options.noseToTail && + this.options.noseToTail !== 'false') || (this.options.smooth && this.options.smooth !== 'false') ) { let array = [] @@ -2401,34 +2126,25 @@ class CurvelineObject extends Base { this.computeDistance( array, 2, - this.options['words-name'] + this.options.wordsName ).then(res => { - _this.options.fitLengthByMeter = res - _this.lengthUnit = _this.options['length-unit'] + _this.lengthByMeter = res + this.lengthChangeCallBack && this.lengthChangeCallBack() + cd && cd() }) } else { let _this = this this.computeDistance( _this.smoothHandle(positions), 2, - this.options['words-name'] + this.options.wordsName ).then(res => { - _this.options.fitLengthByMeter = res - _this.lengthUnit = _this.options['length-unit'] - + _this.lengthByMeter = res + this.lengthChangeCallBack && this.lengthChangeCallBack() + cd && cd() }) } - let _this = this - this.computeDistance( - this.smoothHandle(positions), - 2, - this.options['words-name'] - ).then(res => { - _this.options.lengthByMeter = res - _this.lengthUnit = this.options['length-unit'] - }) - return fromDegreesArray } @@ -2443,7 +2159,7 @@ class CurvelineObject extends Base { let linestring = turf.lineString(linePositions) let buffered = turf.buffer( linestring, - this.options['extend-width'] / 1000, + this.options.extendWidth / 1000, { units: 'kilometers' } ) @@ -2469,7 +2185,7 @@ class CurvelineObject extends Base { positions: Cesium.Cartesian3.fromDegreesArray(outerHole), holes: holes }, - material: Cesium.Color.fromCssColorString(this.options['extend-color']) + material: Cesium.Color.fromCssColorString(this.options.extendColor) }) } else { this.entity.polygon = undefined @@ -2485,10 +2201,10 @@ class CurvelineObject extends Base { this.color = this.originalOptions.color this.lineWidth = this.originalOptions.width this.lineType = this.originalOptions.type - this.noseToTail = this.originalOptions['nose-to-tail'] + this.noseToTail = this.originalOptions.noseToTail this.extend = this.originalOptions.extend - this.extendWidth = this.originalOptions['extend-width'] - this.extendColor = this.originalOptions['extend-color'] + this.extendWidth = this.originalOptions.extendWidth + this.extendColor = this.originalOptions.extendColor this.labelShow = this.originalOptions.label.show this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize @@ -2501,18 +2217,15 @@ class CurvelineObject extends Base { this.labelLineColor = this.originalOptions.label.lineColor this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0] this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1] - this.instruct = this.originalOptions.instruct - this.operatingPoint = this.originalOptions.operatingPoint - 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.attributeVr = this.options.attribute.vr.content + // this.attributeCamera = this.options.attribute.camera.content + // this.attributeGoods = this.options.attribute.goods.content this.rotate = this.originalOptions.rotate this.speed = this.originalOptions.speed - this.dashSize = this.originalOptions.dashSize + // this.dashSize = this.originalOptions.dashSize this.space = this.originalOptions.space - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() + // this.cameraSelect && this.cameraSelect() + // this.goodsSelect && this.goodsSelect() this.heightMode = this.options.heightMode @@ -2537,94 +2250,34 @@ class CurvelineObject extends Base { // ] } - instructSubmit() { - this.Dialog.instructSubmit && - this.Dialog.instructSubmit( - this.options.id, - this.options.label.text, - this.instruct - ) - this.originalOptions.instruct = this.instruct - } + // _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() + // } + // } - operatingPointSubmit() { - this.Dialog.operatingPointSubmit && - this.Dialog.operatingPointSubmit( - this.options.id, - this.options.label.text, - this.operatingPoint - ) - this.originalOptions.operatingPoint = this.operatingPoint - } - - _addLink() { - 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() - // let input = document.createElement('input'); - // input.type = "file"; - // input.accept = ".mp4, .pdf" - // input.click() - // input.addEventListener('change', (event) => { - // if (input.value) { - // this.options.attribute.link.content.push({ - // name: '链接', - // url: input.value - // }) - // this.attributeLink = this.options.attribute.link.content - // } - // }) - } - } - 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 - } + // addAttributeRr(vr) { + // this.options.attribute.vr.content.push({ + // name: '全景图', + // url: vr + // }) + // this.attributeVr = this.options.attribute.vr.content + // } /** * 飞到 @@ -2934,18 +2587,19 @@ class CurvelineObject extends Base { // } // } - static nodeEdit(that, start = true) { - that.positionEditing = false + nodeEdit(cd) { + this.positionEditing = false if (YJ.Measure.GetMeasureStatus()) { } else { - CurvelineObject.closeNodeEdit(that) - that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk) - that.event = new MouseEvent(that.sdk) - that.ControllerObject = new Controller(that.sdk) + this.closeNodeEdit() + this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk) + this.event = new MouseEvent(this.sdk) + this.ControllerObject = new Controller(this.sdk) + this._nodeEditCallback = cd let selectPoint - that.event.mouse_left((movement, cartesian) => { - var pick = that.sdk.viewer.scene.pick(movement.position) + this.event.mouse_left((movement, cartesian) => { + var pick = this.sdk.viewer.scene.pick(movement.position) if ( pick && pick.id && @@ -2953,30 +2607,30 @@ class CurvelineObject extends Base { pick.id.name === 'node-secondary-edit-point' ) { selectPoint = pick.id - that.ControllerObject.position = - that.options.positions[selectPoint.index] - that.ControllerObject.editTranslational() - that.tip && that.tip.destroy() - that.ControllerObject.controllerCallBack = params => { + this.ControllerObject.position = + this.options.positions[selectPoint.index] + this.ControllerObject.editTranslational() + this.tip && this.tip.destroy() + this.ControllerObject.controllerCallBack = params => { if (selectPoint.index === 0) { - that.label.position = [ + this.label.position = [ params.position.lng, params.position.lat, params.position.alt ] - that.options.label.position = { + this.options.label.position = { lng: params.position.lng, lat: params.position.lat, alt: params.position.alt } } - that.options.positions[selectPoint.index] = params.position - that._elms.lng && (that._elms.lng[selectPoint.index].innerHTML = params.position.lng.toFixed(8)) - that._elms.lngInput && (that._elms.lngInput[selectPoint.index].value = params.position.lng.toFixed(8)) - that._elms.lat && (that._elms.lat[selectPoint.index].innerHTML = params.position.lat.toFixed(8)) - that._elms.latInput && (that._elms.latInput[selectPoint.index].value = params.position.lat.toFixed(8)) - that._elms.alt && (that._elms.alt[selectPoint.index].innerHTML = params.position.alt.toFixed(2)) - that._elms.altInput && (that._elms.altInput[selectPoint.index].value = params.position.alt.toFixed(2)) + this.options.positions[selectPoint.index] = params.position + this._elms.lng && (this._elms.lng[selectPoint.index].innerHTML = params.position.lng.toFixed(8)) + this._elms.lngInput && (this._elms.lngInput[selectPoint.index].value = params.position.lng.toFixed(8)) + this._elms.lat && (this._elms.lat[selectPoint.index].innerHTML = params.position.lat.toFixed(8)) + this._elms.latInput && (this._elms.latInput[selectPoint.index].value = params.position.lat.toFixed(8)) + this._elms.alt && (this._elms.alt[selectPoint.index].innerHTML = params.position.alt.toFixed(2)) + this._elms.altInput && (this._elms.altInput[selectPoint.index].value = params.position.alt.toFixed(2)) selectPoint.position = Cesium.Cartesian3.fromDegrees( params.position.lng, params.position.lat, @@ -2986,65 +2640,69 @@ class CurvelineObject extends Base { } }) - that.event.mouse_right((movement, cartesian) => { - for (let i = 0; i < that.nodePoints.length; i++) { - that.sdk.viewer.entities.remove(that.nodePoints[i]) + this.event.mouse_right((movement, cartesian) => { + for (let i = 0; i < this.nodePoints.length; i++) { + this.sdk.viewer.entities.remove(this.nodePoints[i]) } - that.nodePoints = [] - that.event.destroy() - that.tip && that.tip.destroy() - that.tip = null - that.ControllerObject.destroy() + this.nodePoints = [] + this.event.destroy() + this.tip && this.tip.destroy() + this.tip = null + this.ControllerObject.destroy() - let fromDegreesArray = that.renewPositions(that.options.positions) - that.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray) + let fromDegreesArray = this.renewPositions(this.options.positions) + this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray) + YJ.Measure.SetMeasureStatus(false) + this._nodeEditCallback = null }) - that.event.mouse_move((movement, cartesian) => { - that.tip.setPosition( + this.event.mouse_move((movement, cartesian) => { + this.tip.setPosition( cartesian, movement.endPosition.x, movement.endPosition.y ) }) - that.entity.polyline.positions = new Cesium.CallbackProperty(function () { - let fromDegreesArray = that.renewPositions(that.options.positions) + this.entity.polyline.positions = new Cesium.CallbackProperty( () => { + let fromDegreesArray = this.renewPositions(this.options.positions) + this._nodeEditCallback(this.options.positions, this.lengthByMeter) return Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray) }, false) - for (let i = 0; i < that.options.positions.length; i++) { - let entity = that.sdk.viewer.entities.add({ + for (let i = 0; i < this.options.positions.length; i++) { + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: i, position: Cesium.Cartesian3.fromDegrees( - that.options.positions[i].lng, - that.options.positions[i].lat, - that.options.positions[i].alt + this.options.positions[i].lng, + this.options.positions[i].lat, + this.options.positions[i].alt ), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) } }) - that.nodePoints.push(entity) + this.nodePoints.push(entity) } } } - static closeNodeEdit(that) { - that.ControllerObject && that.ControllerObject.destroy() - that.event && that.event.destroy() - that.tip && that.tip.destroy() - that.tip = null + closeNodeEdit() { + this.ControllerObject && this.ControllerObject.destroy() + 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 = [] + this.nodePoints = [] + this._nodeEditCallback = null } /** @@ -3076,7 +2734,7 @@ class CurvelineObject extends Base { } this.operate.positionEditing = status if (status === true) { - CurvelineObject.closeNodeEdit(this) + this.closeNodeEdit() this.event && this.event.destroy() this.event = new MouseEvent(this.sdk) this.tip && this.tip.destroy() @@ -3193,7 +2851,12 @@ class CurvelineObject extends Base { this.previous.positions = positionsLngLat // this.entity.polyline.positionsLngLat = positionsLngLat - let fromDegreesArray = this.renewPositions(this.options.positions) + let fromDegreesArray = this.renewPositions(this.options.positions, ()=>{ + if(this._positionEditingCallback) { + this._positionEditingCallback() + this._positionEditingCallback = null + } + }) this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights( fromDegreesArray ) @@ -3272,6 +2935,15 @@ class CurvelineObject extends Base { break; case 2: case '2': + this.label.position = [ + this.options.positions[0].lng, + this.options.positions[0].lat, + ] + this.options.label.position = { + lng: this.options.positions[0].lng, + lat: this.options.positions[0].lat, + alt: fromDegreesArray[2] + } break; } } @@ -3280,6 +2952,18 @@ class CurvelineObject extends Base { get positionEditing() { return this.operate.positionEditing } + openPositionEditing(cd) { + this.positionEditing = true + this._positionEditingCallback = cd + } + + get lengthChangeCallBack() { + return this._lengthChangeCallBack + } + + set lengthChangeCallBack (cd) { + this._lengthChangeCallBack = cd + } setDIV(options = { domid: '', x: 10, y: 10 }) { options.x = options.x || options.x === 0 ? options.x : 10 diff --git a/src/Obj/Base/LabelObject/index.js b/src/Obj/Base/LabelObject/index.js index 322dd8a..a5e60e1 100644 --- a/src/Obj/Base/LabelObject/index.js +++ b/src/Obj/Base/LabelObject/index.js @@ -13,12 +13,11 @@ import { } from '../../../Global/cluster/cluster' class LabelObject extends Base { - #updateBillboardImageTimeout - #canvas = document.createElement('canvas') - #canvas2 = document.createElement('canvas') constructor(sdk, options = {}, model) { super(sdk, options) this.model = model + this._canvas = document.createElement('canvas') + this._canvas2 = document.createElement('canvas') this.options.near = options.near || options.near === 0 ? options.near : 2000 this.options.far = options.far || options.far === 0 ? options.far : 100000 this.options.scaleByDistance = options.scaleByDistance || false @@ -69,7 +68,7 @@ class LabelObject extends Base { let id = this.options.id + '-label' let oldEntity = this.sdk.viewer.entities.getById(id) - if(oldEntity) { + if (oldEntity) { this.sdk.viewer.entities.remove(oldEntity) } this.entity = this.sdk.viewer.entities.add({ @@ -492,8 +491,8 @@ class LabelObject extends Base { // } getcanvas() { - const ctx = this.#canvas.getContext('2d') - ctx.clearRect(0, 0, this.#canvas.width, this.#canvas.height); + const ctx = this._canvas.getContext('2d') + ctx.clearRect(0, 0, this._canvas.width, this._canvas.height); ctx.font = this.options.fontSize + 'px ' + this.font let texts = this.options.text.split('\n') let canvasWidth = 0 @@ -511,8 +510,8 @@ class LabelObject extends Base { if (canvasWidth < this.options.lineWidth) { canvasWidth = this.options.lineWidth } - this.#canvas.width = canvasWidth - this.#canvas.height = this.options.pixelOffset + canvasHeight + this._canvas.width = canvasWidth + this._canvas.height = this.options.pixelOffset + canvasHeight const linearGradient = ctx.createLinearGradient( 0, 0, @@ -559,14 +558,14 @@ class LabelObject extends Base { ctx.stroke() ctx.closePath() - const ctx2 = this.#canvas2.getContext('2d') - this.#canvas2.width = this.#canvas.width + 10 - this.#canvas2.height = this.#canvas.height + 10 - ctx2.drawImage(this.#canvas, 5, 5); + const ctx2 = this._canvas2.getContext('2d') + this._canvas2.width = this._canvas.width + 10 + this._canvas2.height = this._canvas.height + 10 + ctx2.drawImage(this._canvas, 5, 5); // const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); // ctx.putImageData(imageData, 40, 40); - return this.#canvas2.toDataURL("image/png") + return this._canvas2.toDataURL("image/png") } remove() { diff --git a/src/Obj/Base/PincerArrowObject/index.js b/src/Obj/Base/PincerArrowObject/index.js index 311e289..d212879 100644 --- a/src/Obj/Base/PincerArrowObject/index.js +++ b/src/Obj/Base/PincerArrowObject/index.js @@ -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 = ` -
-
` + this.options.attribute.link.content[i].name + `
-
` + this.options.attribute.link.content[i].url + `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 = ` -
-
` + this.options.attribute.vr.content[i].name + `
-
` + this.options.attribute.vr.content[i].url + `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 } diff --git a/src/Obj/Base/PolygonObject/index.js b/src/Obj/Base/PolygonObject/index.js index 26ed30c..d6bf490 100644 --- a/src/Obj/Base/PolygonObject/index.js +++ b/src/Obj/Base/PolygonObject/index.js @@ -28,7 +28,6 @@ class PolygonObject 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} 边框颜色 @@ -88,7 +87,6 @@ class PolygonObject extends Base { this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3) this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)' - this.options['area-unit'] = options['area-unit'] || '平方米' this.entity this.event = new MouseEvent(this.sdk) this.operate = {} @@ -130,25 +128,24 @@ class PolygonObject extends Base { 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' + // 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 || [] + + delete this.options.attribute.camera + delete this.options.attribute.vr + delete this.options.attribute.goods + + if (!this.options.positions || this.options.positions.length < 3) { this._error = '多边形最少需要三个坐标!' console.warn(this._error) - window.ELEMENT && - window.ELEMENT.Message({ - message: this._error, - type: 'warning', - duration: 1500 - }) } else { if (!this.options.height && this.options.height !== 0) { let height = this.options.positions[0].alt @@ -222,7 +219,7 @@ class PolygonObject extends Base { } let positions = this.options.positions let heightModeName = '' - PolygonObject.closeNodeEdit(this) + this.closeNodeEdit() let ground = false let disabled = false this.renewPositions() @@ -258,14 +255,6 @@ class PolygonObject extends Base { this._elms.heightModeObject && (this._elms.heightModeObject.legp_searchActive( heightModeName )) - if (disabled) { - this._elms.heightBox && (this._elms.heightBox.className = 'input-number input-number-unit-1 height-box disabled'); - this._elms.heightConfirm && this._elms.heightConfirm.setAttribute('disabled', 'disabled'); - } - else { - this._elms.heightBox && (this._elms.heightBox.className = 'input-number input-number-unit-1 height-box'); - this._elms.heightConfirm && this._elms.heightConfirm.removeAttribute('disabled'); - } }, 50); } @@ -347,49 +336,6 @@ class PolygonObject 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 } @@ -607,374 +553,6 @@ class PolygonObject 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 = - ` -
-
` + - this.options.attribute.link.content[i].name + - `
-
` + - this.options.attribute.link.content[i].url + - `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 = - ` -
-
` + - this.options.attribute.vr.content[i].name + - `
-
` + - this.options.attribute.vr.content[i].url + - `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 ground if (that.heightMode == 2) { @@ -1065,12 +643,17 @@ class PolygonObject extends Base { lat: centroid.geometry.coordinates[1] }, objectsToExclude) } - if (!that.options.label.position) { - that.options.label.position = { - lng: centroid.geometry.coordinates[0], - lat: centroid.geometry.coordinates[1], - alt: height - } + // if (!that.options.label.position) { + // that.options.label.position = { + // lng: centroid.geometry.coordinates[0], + // lat: centroid.geometry.coordinates[1], + // alt: height + // } + // } + that.options.label.position = { + lng: centroid.geometry.coordinates[0], + lat: centroid.geometry.coordinates[1], + alt: height } // 标签 that.label = new LabelObject(that.sdk, { @@ -1098,6 +681,7 @@ class PolygonObject extends Base { // 编辑框 async edit(state) { + return let _this = this this.originalOptions = this.deepCopyObj(this.options) @@ -1664,9 +1248,7 @@ class PolygonObject 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.height = this.originalOptions.height - this.areaUnit = this.originalOptions['area-unit'] this.labelShow = this.originalOptions.label.show this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize @@ -1679,12 +1261,6 @@ class PolygonObject extends Base { this.labelLineColor = this.originalOptions.label.lineColor this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0] this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1] - this.attributeLink = this.options.attribute.link.content - this.attributeCamera = this.options.attribute.camera.content - this.attributeVr = this.options.attribute.vr.content - this.attributeGoods = this.options.attribute.goods.content - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() this.heightMode = this.options.heightMode let positions = this.options.positions @@ -1841,78 +1417,6 @@ class PolygonObject 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 - } - - /** - * 打开富文本框 - */ - openRichTextEditor(e) { - richText.open( - this.options.id, - this.options.name, - this.options.richTextContent - ) - richText.primaryCallBack = content => { - this.options.richTextContent = content - } - } - /**@desc 打开平移功能 * * @memberOf Source @@ -1920,7 +1424,7 @@ class PolygonObject extends Base { * * */ set positionEditing(status) { - PolygonObject.closeNodeEdit(this) + this.closeNodeEdit() if (YJ.Measure.GetMeasureStatus() || !this.sdk || !this.sdk.viewer || !this.entity) { return } @@ -1993,6 +1497,11 @@ class PolygonObject extends Base { this.previous = null fromDegreesArray = [] this.heightMode = this.heightMode + + if(this._positionEditingCallback) { + this._positionEditingCallback() + this._positionEditingCallback = null + } } this.event.mouse_move((movement, cartesian) => { let position84 = this.cartesian3Towgs84(cartesian, this.sdk.viewer) @@ -2179,119 +1688,39 @@ class PolygonObject extends Base { return this.operate.positionEditing } - static EventBinding(that, elements) { - for (let i = 0; i < elements.length; i++) { - let Event = [] - let isEvent = false - let removeName = [] - if (!elements[i] || !elements[i].attributes) { - continue - } - for (let m of elements[i].attributes) { - switch (m.name) { - case '@model': { - isEvent = true - if (elements[i].type == 'checkbox') { - Event.push(e => { - that[m.value] = e.target.checked - }) - elements[i].checked = that[m.value] - } else { - Event.push(e => { - let value = e.target.value - if (e.target.type == 'number') { - if (e.data != '.' && (e.data != '-' || e.target.value)) { - value = Number(value) - if (e.target.max && value > Number(e.target.max)) { - value = Number(e.target.max) - } - if (e.target.min && value < Number(e.target.min)) { - value = Number(e.target.min) - } - that[m.value] = value - } - } else { - that[m.value] = value - } - }) - if (elements[i].nodeName == 'IMG') { - elements[i].src = that[m.value] - } else { - elements[i].value = that[m.value] - } - } - if (that._elms[m.value]) { - that._elms[m.value].push(elements[i]) - } else { - that._elms[m.value] = [elements[i]] - } - removeName.push(m.name) - break - } - case '@click': { - elements[i].addEventListener('click', e => { - if (typeof that[m.value] === 'function') { - that[m.value](e) - } - }) - removeName.push(m.name) - // elements[i].attributes.removeNamedItem(m.name) - break - } - case '@change': { - isEvent = true - Event.push(e => { - let value = e.target.value - if (e.target.type == 'number' && value != '') { - value = Number(value) - e.target.value = value - } - if (typeof that[m.value] === 'function') { - that[m.value](e, value) - } - }) - break - } - } - // elements[i].attributes[m] = undefined - } - for (let n = 0; n < removeName.length; n++) { - elements[i].attributes.removeNamedItem(removeName[n]) - } - - if (isEvent) { - let ventType = 'input' - if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') { - ventType = 'change' - } - elements[i].addEventListener(ventType, e => { - for (let t = 0; t < Event.length; t++) { - Event[t](e) - } - }) - } - } + openPositionEditing(cd) { + this.positionEditing = true + this._positionEditingCallback = cd } - static nodeEdit(that, cb = () => { }) { - that.positionEditing = false + get areaChangeCallBack() { + return this._areaChangeCallBack + } + + set areaChangeCallBack (cd) { + this._areaChangeCallBack = cd + } + + nodeEdit(cb = () => { }) { + this.positionEditing = false setTimeout(() => { if (YJ.Measure.GetMeasureStatus()) { cb('上一次测量未结束') } else { YJ.Measure.SetMeasureStatus(true) - that.picking = false - that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk) - that.event = new MouseEvent(that.sdk) - that.nodePoints = [] + this.picking = false + this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk) + this.event = new MouseEvent(this.sdk) + this.nodePoints = [] + let _this = this let selectPoint let originalPosition let newpositions = [] 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 + this.options.positions[i].lng, + this.options.positions[i].lat ) } newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray) @@ -2299,82 +1728,82 @@ class PolygonObject extends Base { let added = false let leftEvent = async (movement, cartesian) => { if (selectPoint) { - that.options.positions[selectPoint.index] = that.cartesian3Towgs84( + this.options.positions[selectPoint.index] = this.cartesian3Towgs84( cartesian, - that.sdk.viewer + this.sdk.viewer ) - originalPosition = that.options.positions[selectPoint.index] + originalPosition = this.options.positions[selectPoint.index] added = true - let potHeight = await that.getClampToHeight( - that.options.positions[selectPoint.index] + let potHeight = await this.getClampToHeight( + this.options.positions[selectPoint.index] ) - let entity = that.sdk.viewer.entities.add({ + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', position: Cesium.Cartesian3.fromDegrees( - that.options.positions[selectPoint.index].lng, - that.options.positions[selectPoint.index].lat, + this.options.positions[selectPoint.index].lng, + this.options.positions[selectPoint.index].lat, potHeight ), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) } }) - that.nodePoints.splice(selectPoint.index, 0, entity) - that.options.positions.splice( + this.nodePoints.splice(selectPoint.index, 0, entity) + this.options.positions.splice( selectPoint.index, 0, - that.options.positions[selectPoint.index] + this.options.positions[selectPoint.index] ) - let positions = that.options.positions + let positions = this.options.positions let fromDegreesArray = [] for (let i = 0; i < positions.length; i++) { fromDegreesArray.push(positions[i].lng, positions[i].lat) } - that.positions = Cesium.Cartesian3.fromDegreesArray( + this.positions = Cesium.Cartesian3.fromDegreesArray( fromDegreesArray ) newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray) - let objectsToExclude = [...that.sdk.viewer.entities.values] - if (that.options.positions.length < 3) { - that + let objectsToExclude = [...this.sdk.viewer.entities.values] + if (this.options.positions.length < 3) { + this .getClampToHeight({ - lng: that.options.positions[0].lng, - lat: that.options.positions[0].lat + lng: this.options.positions[0].lng, + lat: this.options.positions[0].lat }, objectsToExclude) .then(height => { - that.label.position = [ - that.options.positions[0].lng, - that.options.positions[0].lat, + this.label.position = [ + this.options.positions[0].lng, + this.options.positions[0].lat, height ] }) } else { let positions = [[]] - for (let i = 0; i < that.options.positions.length; i++) { + for (let i = 0; i < this.options.positions.length; i++) { positions[0].push([ - that.options.positions[i].lng, - that.options.positions[i].lat + this.options.positions[i].lng, + this.options.positions[i].lat ]) } positions[0].push([ - that.options.positions[0].lng, - that.options.positions[0].lat + this.options.positions[0].lng, + this.options.positions[0].lat ]) let polygon = turf.polygon(positions) let centroid = turf.centroid(polygon) - that + 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 @@ -2382,29 +1811,31 @@ class PolygonObject extends Base { }) } - that.options.areaByMeter = that.computeArea(that.options.positions) - switch (that.options['area-unit']) { - case '平方米': - that.area = that.options.areaByMeter - break - case '平方千米': - that.area = Number( - (that.options.areaByMeter / 1000000).toFixed(8) - ) - break - case '亩': - that.area = Number( - (that.options.areaByMeter / 666.6666667).toFixed(4) - ) - break - case '公顷': - that.area = Number((that.options.areaByMeter / 10000).toFixed(6)) - break - default: - that.area = that.options.areaByMeter - } + this.areaByMeter = this.computeArea(this.options.positions) + this.areaChangeCallBack && this.areaChangeCallBack() + cb(null, this.options.positions, this.areaByMeter) + // switch (this.options['area-unit']) { + // 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 + // } } else { - var pick = that.sdk.viewer.scene.pick(movement.position) + var pick = this.sdk.viewer.scene.pick(movement.position) if ( pick && pick.id && @@ -2412,40 +1843,40 @@ class PolygonObject extends Base { pick.id.name === 'node-secondary-edit-point' ) { selectPoint = pick.id - that.nodePoints.splice(pick.id.index, 1) - that.sdk.viewer.entities.remove(pick.id) - that.tip.set_text('左键开始,右键结束,CTRL+右键撤销') - originalPosition = that.cartesian3Towgs84( + this.nodePoints.splice(pick.id.index, 1) + this.sdk.viewer.entities.remove(pick.id) + this.tip.set_text('左键开始,右键结束,CTRL+右键撤销') + originalPosition = this.cartesian3Towgs84( selectPoint.position.getValue(), - that.sdk.viewer + this.sdk.viewer ) } } } let rightEvent = (movement, cartesian) => { if (selectPoint) { - that.options.positions[selectPoint.index] = originalPosition - // that.options.positions.splice(selectPoint.index, 1) + this.options.positions[selectPoint.index] = originalPosition + // this.options.positions.splice(selectPoint.index, 1) if (added) { - that.options.positions.splice(selectPoint.index, 1) + this.options.positions.splice(selectPoint.index, 1) } - cb(null, that.options.positions) + cb(null, this.options.positions) } YJ.Measure.SetMeasureStatus(false) - that.event.destroy() - that.tip.destroy() - that.heightMode = that.heightMode + this.event.destroy() + this.tip.destroy() + this.heightMode = this.heightMode } - that.entity.polyline.clampToGround = true - that.entity.polyline.arcType = Cesium.ArcType.GEODESIC - that.entity.polygon.perPositionHeight = false - that.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () { + this.entity.polyline.clampToGround = true + this.entity.polyline.arcType = Cesium.ArcType.GEODESIC + this.entity.polygon.perPositionHeight = false + this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () { return new Cesium.PolygonHierarchy(newpositions) }, false) - that.entity.polyline.positions = new Cesium.CallbackProperty(function () { + this.entity.polyline.positions = new Cesium.CallbackProperty(function () { if (newpositions.length >= 3) { return [ ...newpositions, @@ -2458,41 +1889,41 @@ class PolygonObject extends Base { } }, false) - let objectsToExclude = [...that.sdk.viewer.entities.values] - if (that.options.positions.length < 3) { - that + let objectsToExclude = [...this.sdk.viewer.entities.values] + if (this.options.positions.length < 3) { + this .getClampToHeight({ - lng: that.options.positions[0].lng, - lat: that.options.positions[0].lat + lng: this.options.positions[0].lng, + lat: this.options.positions[0].lat }, objectsToExclude) .then(height => { - that.label.position = [ - that.options.positions[0].lng, - that.options.positions[0].lat, + this.label.position = [ + this.options.positions[0].lng, + this.options.positions[0].lat, height ] }) } else { let positions = [[]] - for (let i = 0; i < that.options.positions.length; i++) { + for (let i = 0; i < this.options.positions.length; i++) { positions[0].push([ - that.options.positions[i].lng, - that.options.positions[i].lat + this.options.positions[i].lng, + this.options.positions[i].lat ]) } positions[0].push([ - that.options.positions[0].lng, - that.options.positions[0].lat + this.options.positions[0].lng, + this.options.positions[0].lat ]) let polygon = turf.polygon(positions) let centroid = turf.centroid(polygon) - that + 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 @@ -2501,61 +1932,61 @@ class PolygonObject extends Base { } setTimeout(() => { - that.event.mouse_left(leftEvent) + this.event.mouse_left(leftEvent) - that.event.mouse_right(rightEvent) + this.event.mouse_right(rightEvent) - that.event.mouse_move((movement, cartesian) => { + this.event.mouse_move((movement, cartesian) => { if (selectPoint) { - that.options.positions[selectPoint.index] = that.cartesian3Towgs84( + this.options.positions[selectPoint.index] = this.cartesian3Towgs84( cartesian, - that.sdk.viewer + this.sdk.viewer ) - let positions = that.options.positions + let positions = this.options.positions let fromDegreesArray = [] for (let i = 0; i < positions.length; i++) { fromDegreesArray.push(positions[i].lng, positions[i].lat) } - that.positions = Cesium.Cartesian3.fromDegreesArray( + this.positions = Cesium.Cartesian3.fromDegreesArray( fromDegreesArray ) newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray) - let objectsToExclude = [...that.sdk.viewer.entities.values] - if (that.options.positions.length < 3) { - that + let objectsToExclude = [...this.sdk.viewer.entities.values] + if (this.options.positions.length < 3) { + this .getClampToHeight({ - lng: that.options.positions[0].lng, - lat: that.options.positions[0].lat + lng: this.options.positions[0].lng, + lat: this.options.positions[0].lat }, objectsToExclude) .then(height => { - that.label.position = [ - that.options.positions[0].lng, - that.options.positions[0].lat, + this.label.position = [ + this.options.positions[0].lng, + this.options.positions[0].lat, height ] }) } else { let positions = [[]] - for (let i = 0; i < that.options.positions.length; i++) { + for (let i = 0; i < this.options.positions.length; i++) { positions[0].push([ - that.options.positions[i].lng, - that.options.positions[i].lat + this.options.positions[i].lng, + this.options.positions[i].lat ]) } positions[0].push([ - that.options.positions[0].lng, - that.options.positions[0].lat + this.options.positions[0].lng, + this.options.positions[0].lat ]) let polygon = turf.polygon(positions) let centroid = turf.centroid(polygon) - that + 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 @@ -2563,31 +1994,31 @@ class PolygonObject extends Base { }) } } - that.tip.setPosition( + this.tip.setPosition( cartesian, movement.endPosition.x, movement.endPosition.y ) }) - that.event.mouse_right_keyboard_ctrl((movement, cartesian) => { + this.event.mouse_right_keyboard_ctrl((movement, cartesian) => { if (selectPoint) { - that.options.positions.pop() - that.sdk.viewer.entities.remove( - that.nodePoints[that.nodePoints.length - 1] + this.options.positions.pop() + this.sdk.viewer.entities.remove( + this.nodePoints[this.nodePoints.length - 1] ) - if (selectPoint.index === that.options.positions.length) { - if (that.nodePoints[selectPoint.index - 1]) { - selectPoint = that.nodePoints[selectPoint.index - 1] + if (selectPoint.index === this.options.positions.length) { + if (this.nodePoints[selectPoint.index - 1]) { + selectPoint = this.nodePoints[selectPoint.index - 1] } else { selectPoint.index = 0 } } - that.nodePoints.pop() + this.nodePoints.pop() } }) - that.event.gesture_pinck_start((movement, cartesian) => { + this.event.gesture_pinck_start((movement, cartesian) => { let startTime = new Date() let pos = { position: { @@ -2595,7 +2026,7 @@ class PolygonObject 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) { // 长按取消 @@ -2611,46 +2042,46 @@ class PolygonObject extends Base { async function createNodePoints() { // sdk.viewer.scene.primitives - let objectsToExclude = [...that.sdk.viewer.entities.values] - for (let i = 0; i < that.options.positions.length; i++) { - let height = await that.getClampToHeight(that.options.positions[i], objectsToExclude) - let entity = that.sdk.viewer.entities.add({ + let objectsToExclude = [..._this.sdk.viewer.entities.values] + for (let i = 0; i < _this.options.positions.length; i++) { + let height = await _this.getClampToHeight(_this.options.positions[i], objectsToExclude) + let entity = _this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: i, position: Cesium.Cartesian3.fromDegrees( - that.options.positions[i].lng, - that.options.positions[i].lat, + _this.options.positions[i].lng, + _this.options.positions[i].lat, height ), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: _this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) } }) - that.nodePoints.push(entity) + _this.nodePoints.push(entity) } } } }, 50); } - static closeNodeEdit(that) { - if (!that.sdk || !that.sdk.viewer) { + closeNodeEdit() { + if (!this.sdk || !this.sdk.viewer) { return } 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) { @@ -2805,8 +2236,8 @@ class PolygonObject extends Base { } // 计算投影面积 - this.options.areaByMeter = this.computeArea(positions) - this.areaUnit = this.areaUnit + this.areaByMeter = this.computeArea(positions) + this.areaChangeCallBack && this.areaChangeCallBack() return fromDegreesArray } diff --git a/src/Obj/Base/PolylineObject/index.js b/src/Obj/Base/PolylineObject/index.js index 5c80f9b..3826b47 100644 --- a/src/Obj/Base/PolylineObject/index.js +++ b/src/Obj/Base/PolylineObject/index.js @@ -18,7 +18,6 @@ import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/S import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' class PolylineObject extends Base { - #unitDataLegpObject /** * @constructor * @param sdk @@ -39,6 +38,12 @@ class PolylineObject extends Base { * @param options.positions[].lng {number} 经度 * @param options.positions[].lat {number} 纬度 * @param options.positions[].alt {number} 高度 + * + * + * @param options.noseToTail=false {boolean} 是否首尾相连 + * + * + * * @param options.label {object} 标签对象 * @param options.label.text {string} 标签文本 * @param options.label.show {string} 标签显隐 @@ -74,21 +79,19 @@ class PolylineObject extends Base { this.options.width = ((options.width || options.width === 0) ? options.width : 3) this.options.color = options.color || '#ff0000' this.options.type = options.type ? Number(options.type) : 0 - this.options['nose-to-tail'] = options['nose-to-tail'] || false + this.options.noseToTail = options.noseToTail || false this.options.smooth = options.smooth || false this.options.extend = options.extend || false - this.options.rotate = options.rotate || true + this.options.rotate = (options.rotate || options.rotate === false) ? options.rotate : true this.options.space = options.space || 1 this.options.speed = options.speed || 10 - this.options.dashSize = options.dashSize || 0.03 - this.options['length-unit'] = options['length-unit'] || '米' - this.options['fit-length-unit'] = options['fit-length-unit'] || '米' - this.options['words-name'] = options['words-name'] || '空间长度' - this.options['extend-width'] = - options['extend-width'] || options['extend-width'] === 0 - ? options['extend-width'] + // this.options.dashSize = options.dashSize || 0.03 + this.options.wordsName = options.wordsName || 0 + this.options.extendWidth = + options.extendWidth || options.extendWidth === 0 + ? options.extendWidth : 10 - this.options['extend-color'] = options['extend-color'] || 'rgba(255,255,80,0.3)' + this.options.extendColor = options.extendColor || 'rgba(255,255,80,0.3)' this.options.show = options.show || options.show === false ? options.show : true this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2 @@ -124,22 +127,25 @@ class PolylineObject extends Base { ? options.label.far : 100000 } - this.options.instruct = options.instruct || '' - this.options.operatingPoint = options.operatingPoint || '' this.options.attribute = options.attribute || {} this.options.attribute.link = this.options.attribute.link || {} this.options.attribute.link.content = this.options.attribute.link.content || [] - this.options.attribute.camera = this.options.attribute.camera || {} - this.options.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' + // 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 || [] + + delete this.options.attribute.camera + delete this.options.attribute.vr + delete this.options.attribute.goods + + this.operate = {} this.nodePoints = [] this.unitNum = 0 @@ -210,17 +216,17 @@ class PolylineObject extends Base { // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) } - get dashSize() { - return this.options.dashSize - } + // get dashSize() { + // return this.options.dashSize + // } - set dashSize(v) { - this.options.dashSize = v - let params = { ...this.options } - params.speed = this.inputSpeed - // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) - this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) - } + // set dashSize(v) { + // this.options.dashSize = v + // let params = { ...this.options } + // params.speed = this.inputSpeed + // // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options) + // this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) + // } get rotate() { return this.options.rotate @@ -228,7 +234,7 @@ class PolylineObject extends Base { set rotate(v) { this.options.rotate = v - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() this._elms.rotate && this._elms.rotate.forEach(item => { item.checked = v @@ -253,71 +259,11 @@ class PolylineObject extends Base { this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, params) } - get length() { - return this.options.length - } - - set length(v) { - this.options.length = v - //判断数值是否大于1000m - - this._elms.length && - this._elms.length.forEach(item => { - item.value = v - }) - } - - get fitLength() { - return this.options.fitLength - } - - set fitLength(v) { - this.options.fitLength = v - this._elms.fitLength && - this._elms.fitLength.forEach(item => { - item.value = v - }) - } - - get lengthUnit() { - return this.options['length-unit'] - } - set lengthUnit(v) { - this.unitNum++ - this.options['length-unit'] = v - this._elms.lengthUnit && - this._elms.lengthUnit.forEach(item => { - item.value = v - }) - this.#unitDataLegpObject && this.#unitDataLegpObject.legp_searchActive(v) - if (this.options.lengthByMeter) { - if (this.unitNum > 2) { - switch (v) { - case '米': - this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter - break - case '千米': - this.length = this.noseToTail ? (this.options.fitLengthByMeter / 1000).toFixed(5) : (this.options.lengthByMeter / 1000).toFixed(5) - break - default: - this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter - break - } - } else { - let length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter - this.lengthUnit = length > 1000 || length == 1000 ? '千米' : '米' - } - } - } get wordsName() { - return this.options['words-name'] + return this.options.wordsName } set wordsName(v) { - this.options['words-name'] = v - this._elms.wordsName && - this._elms.wordsName.forEach(item => { - item.value = v - }) + this.options.wordsName = v let _this = this if (!this.noseToTail) { @@ -334,38 +280,38 @@ class PolylineObject extends Base { // _this.length = res // _this.lengthUnit = '米' // } - _this.options.lengthByMeter = res - _this.lengthUnit = _this.options['length-unit'] + _this.lengthByMeter = res + this.lengthChangeCallBack && this.lengthChangeCallBack() }) } else { let fromDegreesArray = this.renewPositions(this.options.positions) } } - get fitLengthUnit() { - return this.options['fit-length-unit'] - } - set fitLengthUnit(v) { - this.options['fit-length-unit'] = v - this._elms.fitLengthUnit && - this._elms.fitLengthUnit.forEach(item => { - item.value = v - }) - if (this.options.fitLengthByMeter) { - switch (v) { - case '米': - this.fitLength = this.options.fitLengthByMeter - break - case '千米': - this.fitLength = Number( - (this.options.fitLengthByMeter / 1000).toFixed(5) - ) - break - default: - this.fitLength = this.options.fitLengthByMeter - } - } - } + // get fitLengthUnit() { + // return this.options.fitLengthUnit + // } + // set fitLengthUnit(v) { + // this.options.fitLengthUnit = v + // this._elms.fitLengthUnit && + // this._elms.fitLengthUnit.forEach(item => { + // item.value = v + // }) + // if (this.fitLengthByMeter) { + // switch (v) { + // case '米': + // this.fitLength = this.fitLengthByMeter + // break + // case '千米': + // this.fitLength = Number( + // (this.fitLengthByMeter / 1000).toFixed(5) + // ) + // break + // default: + // this.fitLength = this.fitLengthByMeter + // } + // } + // } get lineWidth() { return this.options.width @@ -505,12 +451,12 @@ class PolylineObject extends Base { )) } get noseToTail() { - return this.options['nose-to-tail'] + return this.options.noseToTail } set noseToTail(v) { - this.options['nose-to-tail'] = v - PolylineObject.closeNodeEdit(this) + this.options.noseToTail = v + this.closeNodeEdit() this._elms.noseToTail && this._elms.noseToTail.forEach(item => { item.checked = v @@ -522,7 +468,6 @@ class PolylineObject extends Base { ) this.renewPolygon(fromDegreesArray) } - this.lengthUnit = this.options['length-unit'] // if (v) { // if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) { // let dom = document.getElementsByClassName('input-select-unit')[1] @@ -549,7 +494,7 @@ class PolylineObject extends Base { set smooth(v) { this.options.smooth = v - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() this._elms.smooth && this._elms.smooth.forEach(item => { item.checked = v @@ -570,7 +515,7 @@ class PolylineObject extends Base { this.positionEditing = false this.options.heightMode = (v || v == 0) ? v : 2 let heightModeName = '' - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() let ground = false let disabled = false let fromDegreesArray = this.renewPositions(this.options.positions) @@ -600,24 +545,6 @@ class PolylineObject extends Base { break } - // this.options.lengthByMeter = this.computeDistance( - // this.options.positions, - // 2, - // ground - // ) - // this.lengthUnit = this.lengthUnit - this._elms.heightMode && (this._elms.heightMode.value = heightModeName) - this._elms.heightModeObject && (this._elms.heightModeObject.legp_searchActive( - heightModeName - )) - if (disabled) { - this._elms.heightBox && (this._elms.heightBox.className = 'input-number input-number-unit-1 height-box disabled'); - this._elms.heightConfirm && this._elms.heightConfirm.setAttribute('disabled', 'disabled'); - } - else { - this._elms.heightBox && (this._elms.heightBox.className = 'input-number input-number-unit-1 height-box'); - this._elms.heightConfirm && this._elms.heightConfirm.removeAttribute('disabled'); - } setTimeout(() => { if (ground) { @@ -650,7 +577,7 @@ class PolylineObject extends Base { set extend(v) { this.options.extend = v - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() if (v) { this.heightMode = 2 } @@ -669,11 +596,11 @@ class PolylineObject extends Base { } get extendWidth() { - return this.options['extend-width'] + return this.options.extendWidth } set extendWidth(v) { - this.options['extend-width'] = v + this.options.extendWidth = v this.heightMode = this.heightMode this._elms.extendWidth && this._elms.extendWidth.forEach(item => { @@ -684,10 +611,10 @@ class PolylineObject extends Base { } get extendColor() { - return this.options['extend-color'] + return this.options.extendColor } set extendColor(v) { - this.options['extend-color'] = v + this.options.extendColor = v if (this._elms.extendColor) { this._elms.extendColor.forEach((item, i) => { let extendColorPicker = new YJColorPicker({ @@ -710,7 +637,7 @@ class PolylineObject extends Base { this.entity && this.entity.polygon && (this.entity.polygon.material = Cesium.Color.fromCssColorString( - this.options['extend-color'] + this.options.extendColor )) } @@ -938,394 +865,189 @@ class PolylineObject extends Base { } } - get instruct() { - return this.options.instruct - } - set instruct(v) { - this.options.instruct = v - this._elms.instruct && - this._elms.instruct.forEach(item => { - item.value = v - }) - } - get operatingPoint() { - return this.options.operatingPoint - } - set operatingPoint(v) { - this.options.operatingPoint = v - this._elms.operatingPoint && - this._elms.operatingPoint.forEach(item => { - item.value = v - }) - } + // get attributeCamera() { + // return this.options.attribute.camera.content + // } - get attributeType() { - return this.options.attributeType - } + // set attributeCamera(v) { + // this.options.attribute.camera.content = v + // } - 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 attributeVr() { + // return this.options.attribute.vr.content + // } - get attributeLink() { - return this.options.attribute.link.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 = + // ` + //
+ //
` + + // this.options.attribute.vr.content[i].name + + // `
+ //
` + + // this.options.attribute.vr.content[i].url + + // `
+ //
+ // + // + //
+ //
` + // 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 = ` + //
+ // + //
+ //
+ // + //
+ //
+ // + // + //
` + // 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 + // }, - 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 = - ` -
-
` + - this.options.attribute.link.content[i].name + - `
-
` + - this.options.attribute.link.content[i].url + - `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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.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 + // } + // } + // } + // } + // } - 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 attributeGoods() { + // return this.options.attribute.goods.content + // } - get attributeCamera() { - return this.options.attribute.camera.content - } + // set attributeGoods(v) { + // this.options.attribute.goods.content = v + // } - 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 = - ` -
-
` + - this.options.attribute.vr.content[i].name + - `
-
` + - this.options.attribute.vr.content[i].url + - `
-
- - -
-
` - 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 = ` -
- -
-
- -
-
- - -
` - 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 + get positions() { + return this.options.positions } static async createLabel(that) { @@ -1423,10 +1145,10 @@ class PolylineObject extends Base { that.computeDistance( positions, 2, - that.options['words-name'] + that.options.wordsName ).then(res => { - that.options.lengthByMeter = res - that.lengthUnit = that.options['length-unit'] + that.lengthByMeter = res + that.lengthChangeCallBack && that.lengthChangeCallBack() syncData(that.sdk, that.options.id) }) if (that.options.show) { @@ -1434,7 +1156,7 @@ class PolylineObject extends Base { } - // if (this.options['nose-to-tail']) { + // if (this.options.noseToTail) { // let array = [] // for (let i = 0; i < fromDegreesArray.length; i += 2) { // array.push({ lng: fromDegreesArray[i], lat: fromDegreesArray[i + 1] }) @@ -1582,6 +1304,7 @@ class PolylineObject extends Base { * @param {boolean} state true打开,false关闭 */ async edit(state) { + return let _this = this this.originalOptions = this.deepCopyObj(this.options) if (this._DialogObject && this._DialogObject.close) { @@ -1640,11 +1363,7 @@ class PolylineObject extends Base { }, // 二次编辑回调 secondaryEditCallBack: () => { - this.positionEditing = false - this.noseToTail = false - // this.smooth = false - this.heightMode = 0 - PolylineObject.nodeEdit(this) + this.nodeEdit() } }) this._DialogObject._element.body.className = @@ -1769,9 +1488,9 @@ class PolylineObject extends Base { setTimeout(() => { this.attributeLink = this.options.attribute.link.content - this.attributeVr = this.options.attribute.vr.content - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() + // this.attributeVr = this.options.attribute.vr.content + // this.cameraSelect && this.cameraSelect() + // this.goodsSelect && this.goodsSelect() let tagData = this.attributeSelect let attributeElm = this._DialogObject._element.content.getElementsByClassName( 'attribute-select-box' @@ -1826,7 +1545,7 @@ class PolylineObject extends Base { .getElementsByClassName('input-select-unit')[0] .getElementsByTagName('input')[0] this._elms.wordsName = [nameDataLegpElm] - nameDataLegpElm.value = this.options['words-name'] + nameDataLegpElm.value = this.options.wordsName for (let i = 0; i < nameData.length; i++) { if (nameData[i].value === nameDataLegpElm.value) { nameDataLegpObject.legp_searchActive(nameData[i].value) @@ -1862,14 +1581,13 @@ class PolylineObject extends Base { '.input-select-unit', 1 ) - this.#unitDataLegpObject = unitDataLegpObject if (unitDataLegpObject) { unitDataLegpObject.legp_search(unitData) let unitDataLegpElm = this._DialogObject._element.content .getElementsByClassName('input-select-unit')[1] .getElementsByTagName('input')[0] this._elms.lengthUnit = [unitDataLegpElm] - unitDataLegpElm.value = this.options['length-unit'] + unitDataLegpElm.value = this.options.lengthUnit for (let i = 0; i < unitData.length; i++) { if (unitData[i].value === unitDataLegpElm.value) { unitDataLegpObject.legp_searchActive(unitData[i].value) @@ -1912,7 +1630,7 @@ class PolylineObject extends Base { // .getElementsByClassName('input-select-fit-unit')[0] // .getElementsByTagName('input')[0] // this._elms.fitLengthUnit = [fitUnitDataLegpElm] - // fitUnitDataLegpElm.value = this.options['fit-length-unit'] + // fitUnitDataLegpElm.value = this.options.fitLengthUnit // for (let i = 0; i < fitUnitData.length; i++) { // if (fitUnitData[i].value === fitUnitDataLegpElm.value) { // fitUnitDataLegpObject.legp_searchActive(fitUnitData[i].value) @@ -2154,7 +1872,7 @@ class PolylineObject extends Base { ) this.positionEditing = false - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() }) } @@ -2217,7 +1935,7 @@ class PolylineObject extends Base { lngBox.appendChild(lngInput) lngInput.focus() this.positionEditing = false - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() }) lngInput.addEventListener('blur', () => { lngInput.value = Number(this.options.positions[i].lng.toFixed(8)) @@ -2238,7 +1956,7 @@ class PolylineObject extends Base { latBox.appendChild(latInput) latInput.focus() this.positionEditing = false - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() }) latInput.addEventListener('blur', () => { latInput.value = Number(this.options.positions[i].lat.toFixed(8)) @@ -2262,7 +1980,7 @@ class PolylineObject extends Base { altBox.appendChild(altInput) altInput.focus() this.positionEditing = false - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() }) altInput.addEventListener('blur', () => { altInput.value = Number(this.options.positions[i].alt.toFixed(2)) @@ -2351,7 +2069,7 @@ class PolylineObject extends Base { } // 更新坐标 - renewPositions(positionsArray) { + renewPositions(positionsArray, cd) { if (this._error) { return } @@ -2378,8 +2096,8 @@ class PolylineObject extends Base { let newPositions let fromDegreesArray = [] if ( - this.options['nose-to-tail'] && - this.options['nose-to-tail'] !== 'false' + this.options.noseToTail && + this.options.noseToTail !== 'false' ) { newPositions = [...positions, positions[0]] } else { @@ -2406,8 +2124,8 @@ class PolylineObject extends Base { // 计算长度 if ( - (this.options['nose-to-tail'] && - this.options['nose-to-tail'] !== 'false') || + (this.options.noseToTail && + this.options.noseToTail !== 'false') || (this.options.smooth && this.options.smooth !== 'false') ) { let array = [] @@ -2418,41 +2136,29 @@ class PolylineObject extends Base { alt: fromDegreesArray[i + 2] }) } - // this.options.fitLengthByMeter = this.computeDistance( - // array, - // 2, - // ground - // ) + let _this = this this.computeDistance( array, 2, - this.options['words-name'] + this.options.wordsName ).then(res => { - _this.options.fitLengthByMeter = res - _this.lengthUnit = _this.options['length-unit'] + _this.lengthByMeter = res + this.lengthChangeCallBack && this.lengthChangeCallBack() + cd && cd() }) } else { let _this = this this.computeDistance( positions, 2, - this.options['words-name'] + this.options.wordsName ).then(res => { - _this.options.fitLengthByMeter = res - _this.lengthUnit = _this.options['length-unit'] + _this.lengthByMeter = res + this.lengthChangeCallBack && this.lengthChangeCallBack() + cd && cd() }) } - - let _this = this - this.computeDistance( - positions, - 2, - this.options['words-name'] - ).then(res => { - _this.options.lengthByMeter = res - _this.lengthUnit = this.options['length-unit'] - }) return fromDegreesArray } @@ -2467,7 +2173,7 @@ class PolylineObject extends Base { let linestring = turf.lineString(linePositions) let buffered = turf.buffer( linestring, - this.options['extend-width'] / 1000, + this.options.extendWidth / 1000, { units: 'kilometers' } ) @@ -2493,7 +2199,7 @@ class PolylineObject extends Base { positions: Cesium.Cartesian3.fromDegreesArray(outerHole), holes: holes }, - material: Cesium.Color.fromCssColorString(this.options['extend-color']) + material: Cesium.Color.fromCssColorString(this.options.extendColor) }) } else { this.entity.polygon = undefined @@ -2509,11 +2215,11 @@ class PolylineObject extends Base { this.color = this.originalOptions.color this.lineWidth = this.originalOptions.width this.lineType = this.originalOptions.type - this.noseToTail = this.originalOptions['nose-to-tail'] + this.noseToTail = this.originalOptions.noseToTail this.smooth = this.originalOptions.smooth this.extend = this.originalOptions.extend - this.extendWidth = this.originalOptions['extend-width'] - this.extendColor = this.originalOptions['extend-color'] + this.extendWidth = this.originalOptions.extendWidth + this.extendColor = this.originalOptions.extendColor this.labelShow = this.originalOptions.label.show this.labelColor = this.originalOptions.label.color this.labelFontSize = this.originalOptions.label.fontSize @@ -2523,18 +2229,15 @@ class PolylineObject extends Base { this.labelLineColor = this.originalOptions.label.lineColor this.labelBackgroundColorStart = this.originalOptions.label.backgroundColor[0] this.labelBackgroundColorEnd = this.originalOptions.label.backgroundColor[1] - this.instruct = this.originalOptions.instruct - this.operatingPoint = this.originalOptions.operatingPoint - 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.attributeVr = this.options.attribute.vr.content + // this.attributeCamera = this.options.attribute.camera.content + // this.attributeGoods = this.options.attribute.goods.content this.rotate = this.originalOptions.rotate this.speed = this.originalOptions.speed - this.dashSize = this.originalOptions.dashSize + // this.dashSize = this.originalOptions.dashSize this.space = this.originalOptions.space - this.cameraSelect && this.cameraSelect() - this.goodsSelect && this.goodsSelect() + // this.cameraSelect && this.cameraSelect() + // this.goodsSelect && this.goodsSelect() this.heightMode = this.options.heightMode @@ -2559,94 +2262,34 @@ class PolylineObject extends Base { // ] } - instructSubmit() { - this.Dialog.instructSubmit && - this.Dialog.instructSubmit( - this.options.id, - this.options.label.text, - this.instruct - ) - this.originalOptions.instruct = this.instruct - } + // _addRr() { + // if ( + // this._DialogObject._element.content.getElementsByClassName( + // 'vr_add' + // )[0].value + // ) { + // this.options.attribute.vr.content.push({ + // name: '全景图' + (this.options.attribute.vr.content.length + 1), + // 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() + // } + // } - operatingPointSubmit() { - this.Dialog.operatingPointSubmit && - this.Dialog.operatingPointSubmit( - this.options.id, - this.options.label.text, - this.operatingPoint - ) - this.originalOptions.operatingPoint = this.operatingPoint - } - - _addLink() { - if ( - this._DialogObject._element.content.getElementsByClassName('link_add')[0] - .value - ) { - this.options.attribute.link.content.push({ - name: '链接' + (this.options.attribute.link.content.length + 1), - 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() - // let input = document.createElement('input'); - // input.type = "file"; - // input.accept = ".mp4, .pdf" - // input.click() - // input.addEventListener('change', (event) => { - // if (input.value) { - // this.options.attribute.link.content.push({ - // name: '链接' + (this.options.attribute.link.content.length + 1), - // url: input.value - // }) - // this.attributeLink = this.options.attribute.link.content - // } - // }) - } - } - addAttributeLink(link) { - this.options.attribute.link.content.push({ - name: '链接' + (this.options.attribute.link.content.length + 1), - 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: '全景图' + (this.options.attribute.vr.content.length + 1), - 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: '全景图' + (this.options.attribute.vr.content.length + 1), - url: vr - }) - this.attributeVr = this.options.attribute.vr.content - } + // addAttributeRr(vr) { + // this.options.attribute.vr.content.push({ + // name: '全景图' + (this.options.attribute.vr.content.length + 1), + // url: vr + // }) + // this.attributeVr = this.options.attribute.vr.content + // } /** * 飞到 @@ -2759,21 +2402,6 @@ class PolylineObject 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 - } - } - // static nodeEdit2(that, cb = () => { }) { // that.positionEditing = false // if (YJ.Measure.GetMeasureStatus()) { @@ -2830,7 +2458,7 @@ class PolylineObject extends Base { // 2, // that.ground // ) - // that.lengthUnit = that.options['length-unit'] + // that.lengthUnit = that.options.lengthUnit // } else { // var pick = that.sdk.viewer.scene.pick(movement.position) // if ( @@ -2956,19 +2584,23 @@ class PolylineObject extends Base { // } // } - static nodeEdit(that, start = true) { - that.positionEditing = false + nodeEdit(cb) { + this.positionEditing = false + this.noseToTail = false + // this.smooth = false + this.heightMode = 0 if (YJ.Measure.GetMeasureStatus()) { } else { - PolylineObject.closeNodeEdit(that) + this.closeNodeEdit() YJ.Measure.SetMeasureStatus(true) - that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk) - that.event = new MouseEvent(that.sdk) - that.ControllerObject = new Controller(that.sdk) + this._nodeEditCallback = cb + this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk) + this.event = new MouseEvent(this.sdk) + this.ControllerObject = new Controller(this.sdk) let selectPoint - that.event.mouse_left((movement, cartesian) => { - var pick = that.sdk.viewer.scene.pick(movement.position) + this.event.mouse_left((movement, cartesian) => { + var pick = this.sdk.viewer.scene.pick(movement.position) if ( pick && pick.id && @@ -2976,30 +2608,30 @@ class PolylineObject extends Base { pick.id.name === 'node-secondary-edit-point' ) { selectPoint = pick.id - that.ControllerObject.position = - that.options.positions[selectPoint.index] - that.ControllerObject.editTranslational() - that.tip && that.tip.destroy() - that.ControllerObject.controllerCallBack = params => { + this.ControllerObject.position = + this.options.positions[selectPoint.index] + this.ControllerObject.editTranslational() + this.tip && this.tip.destroy() + this.ControllerObject.controllerCallBack = params => { if (selectPoint.index === 0) { - that.label.position = [ + this.label.position = [ params.position.lng, params.position.lat, params.position.alt ] - that.options.label.position = { + this.options.label.position = { lng: params.position.lng, lat: params.position.lat, alt: params.position.alt } } - that.options.positions[selectPoint.index] = params.position - that._elms.lng && (that._elms.lng[selectPoint.index].innerHTML = params.position.lng.toFixed(8)) - that._elms.lngInput && (that._elms.lngInput[selectPoint.index].value = params.position.lng.toFixed(8)) - that._elms.lat && (that._elms.lat[selectPoint.index].innerHTML = params.position.lat.toFixed(8)) - that._elms.latInput && (that._elms.latInput[selectPoint.index].value = params.position.lat.toFixed(8)) - that._elms.alt && (that._elms.alt[selectPoint.index].innerHTML = params.position.alt.toFixed(2)) - that._elms.altInput && (that._elms.altInput[selectPoint.index].value = params.position.alt.toFixed(2)) + this.options.positions[selectPoint.index] = params.position + this._elms.lng && (this._elms.lng[selectPoint.index].innerHTML = params.position.lng.toFixed(8)) + this._elms.lngInput && (this._elms.lngInput[selectPoint.index].value = params.position.lng.toFixed(8)) + this._elms.lat && (this._elms.lat[selectPoint.index].innerHTML = params.position.lat.toFixed(8)) + this._elms.latInput && (this._elms.latInput[selectPoint.index].value = params.position.lat.toFixed(8)) + this._elms.alt && (this._elms.alt[selectPoint.index].innerHTML = params.position.alt.toFixed(2)) + this._elms.altInput && (this._elms.altInput[selectPoint.index].value = params.position.alt.toFixed(2)) selectPoint.position = Cesium.Cartesian3.fromDegrees( params.position.lng, params.position.lat, @@ -3009,67 +2641,70 @@ class PolylineObject extends Base { } }) - that.event.mouse_right((movement, cartesian) => { - for (let i = 0; i < that.nodePoints.length; i++) { - that.sdk.viewer.entities.remove(that.nodePoints[i]) + this.event.mouse_right((movement, cartesian) => { + for (let i = 0; i < this.nodePoints.length; i++) { + this.sdk.viewer.entities.remove(this.nodePoints[i]) } - that.nodePoints = [] - that.event.destroy() - that.tip && that.tip.destroy() - that.tip = null - that.ControllerObject.destroy() + this.nodePoints = [] + this.event.destroy() + this.tip && this.tip.destroy() + this.tip = null + this.ControllerObject.destroy() - let fromDegreesArray = that.renewPositions(that.options.positions) - that.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray) + let fromDegreesArray = this.renewPositions(this.options.positions) + this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray) YJ.Measure.SetMeasureStatus(false) + this._nodeEditCallback = null }) - that.event.mouse_move((movement, cartesian) => { - that.tip.setPosition( + this.event.mouse_move((movement, cartesian) => { + this.tip.setPosition( cartesian, movement.endPosition.x, movement.endPosition.y ) }) - that.entity.polyline.positions = new Cesium.CallbackProperty(function () { - let fromDegreesArray = that.renewPositions(that.options.positions) + this.entity.polyline.positions = new Cesium.CallbackProperty(() => { + let fromDegreesArray = this.renewPositions(this.options.positions) + this._nodeEditCallback(this.options.positions, this.lengthByMeter) return Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray) }, false) - for (let i = 0; i < that.options.positions.length; i++) { - let entity = that.sdk.viewer.entities.add({ + for (let i = 0; i < this.options.positions.length; i++) { + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: i, position: Cesium.Cartesian3.fromDegrees( - that.options.positions[i].lng, - that.options.positions[i].lat, - that.options.positions[i].alt + this.options.positions[i].lng, + this.options.positions[i].lat, + this.options.positions[i].alt ), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) } }) - that.nodePoints.push(entity) + this.nodePoints.push(entity) } } } - static closeNodeEdit(that) { + closeNodeEdit() { YJ.Measure.SetMeasureStatus(false) - that.ControllerObject && that.ControllerObject.destroy() - that.event && that.event.destroy() - that.tip && that.tip.destroy() - that.tip = null + this.ControllerObject && this.ControllerObject.destroy() + 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 = [] + this.nodePoints = [] + this._nodeEditCallback = null } /** @@ -3101,7 +2736,7 @@ class PolylineObject extends Base { } this.operate.positionEditing = status if (status === true) { - PolylineObject.closeNodeEdit(this) + this.closeNodeEdit() this.event && this.event.destroy() this.event = new MouseEvent(this.sdk) this.tip && this.tip.destroy() @@ -3209,7 +2844,12 @@ class PolylineObject extends Base { this.previous.positions = positionsLngLat // this.entity.polyline.positionsLngLat = positionsLngLat - let fromDegreesArray = this.renewPositions(this.options.positions) + let fromDegreesArray = this.renewPositions(this.options.positions, ()=>{ + if(this._positionEditingCallback) { + this._positionEditingCallback() + this._positionEditingCallback = null + } + }) this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights( fromDegreesArray ) @@ -3289,6 +2929,15 @@ class PolylineObject extends Base { break; case 2: case '2': + this.label.position = [ + this.options.positions[0].lng, + this.options.positions[0].lat + ] + this.options.label.position = { + lng: this.options.positions[0].lng, + lat: this.options.positions[0].lat, + alt: fromDegreesArray[2] + } break; } } @@ -3298,6 +2947,19 @@ class PolylineObject extends Base { return this.operate.positionEditing } + openPositionEditing(cd) { + this.positionEditing = true + this._positionEditingCallback = cd + } + + get lengthChangeCallBack() { + return this._lengthChangeCallBack + } + + set lengthChangeCallBack (cd) { + this._lengthChangeCallBack = cd + } + setDIV(options = { domid: '', x: 10, y: 10 }) { options.x = options.x || options.x === 0 ? options.x : 10 options.y = options.y || options.y === 0 ? options.y : 10 diff --git a/src/Obj/Base/TextObject/GroundText/index.js b/src/Obj/Base/TextObject/GroundText/index.js index a727867..1f0bbc8 100644 --- a/src/Obj/Base/TextObject/GroundText/index.js +++ b/src/Obj/Base/TextObject/GroundText/index.js @@ -17,6 +17,7 @@ class GroundText extends Base { * @param options.id {string} 唯一标识 * @param options.show=true {boolean} 显示/隐藏 * @param options.text {string} 文字 + * @param options.color=#FFC107 {string} 颜色 * @param options.angle=0 {number} 旋转角度 * @param options.scale=1 {number} 缩放比例 * @param options.speed=1 {number} 文字滚动速度 @@ -49,20 +50,21 @@ class GroundText extends Base { textArray.splice(70 - textArray.length) } this.options.text = textArray.join('\n') - this.options.name = this.options.text this.options.show = options.show || options.show === false ? options.show : true this.options.angle = options.angle || 0 this.options.scale = options.scale || options.scale === 0 ? options.scale : 1 - this.options.fontSize = options.fontSize || 20 - this.options.duration = - options.duration || options.duration === 0 ? options.duration : 50000 + // this.options.fontSize = options.fontSize || 20 + // this.options.duration = + // options.duration || options.duration === 0 ? options.duration : 50000 this.options.speed = options.speed || options.speed === 0 ? options.speed : 1 this.options.color = options.color || '#FFC107' this.options.position = options.position + delete this.options.name + if (!this.options.position && this.options.positions) { this.options.position = { lng: (this.options.positions[0].lng + this.options.positions[1].lng) / 2, lat: (this.options.positions[0].lat + this.options.positions[1].lat) / 2 } let point1 = turf.point([this.options.positions[0].lng, this.options.positions[0].lat]); @@ -70,7 +72,7 @@ class GroundText extends Base { let options = { units: 'miles' }; let distance1 = turf.rhumbDistance(point1, point2, options); - + // 计算两点与x轴正方向的夹角(弧度) function calculateAngle(pointA, pointB) { @@ -80,7 +82,7 @@ class GroundText extends Base { } let angleRadians = calculateAngle([this.options.positions[0].lng, this.options.positions[0].lat], [this.options.positions[1].lng, this.options.positions[1].lat]); - this.options.angle = (360+Cesium.Math.toDegrees(angleRadians))%360 + this.options.angle = (360 + Cesium.Math.toDegrees(angleRadians)) % 360 let gap = Math.abs(Math.cos((Math.PI / 180) * this.options.position.lat)) * @@ -98,10 +100,11 @@ class GroundText extends Base { let to = turf.point([lng2, lat]); let distance2 = turf.rhumbDistance(from, to, options); let latRadians = Cesium.Math.toRadians(this.options.position.lat) - distance2 = distance2 * (1+(Math.abs(Math.sin(angleRadians)*Math.tan(latRadians)*Math.sin(latRadians)*Math.sin(latRadians)))) + distance2 = distance2 * (1 + (Math.abs(Math.sin(angleRadians) * Math.tan(latRadians) * Math.sin(latRadians) * Math.sin(latRadians)))) this.options.scale = distance1 / distance2 } + this.duration = 50000 this.entity this._positionEditing = false this.Dialog = _Dialog @@ -137,6 +140,9 @@ class GroundText extends Base { }) } + get name() { + return + } get text() { return this.options.text } @@ -172,7 +178,7 @@ class GroundText extends Base { image: canvas.toDataURL('image/png'), color: this.options.color, repeat: new Cesium.Cartesian2(1.0, 1.0), - duration: this.options.duration / this.options.speed, + duration: this.duration / this.options.speed, fltr: false, is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false }) @@ -219,26 +225,26 @@ class GroundText extends Base { }) } - get duration() { - return this.options.duration - } + // get duration() { + // return this.options.duration + // } - set duration(v) { - this.options.duration = v - let canvas = this.getcanvas() - this.entity.rectangle.material = new Cesium.CustomMaterialSource({ - image: canvas.toDataURL('image/png'), - color: this.options.color, - repeat: new Cesium.Cartesian2(1.0, 1.0), - duration: this.options.duration / this.options.speed, - fltr: false, - is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false - }) - this._elms.duration && - this._elms.duration.forEach(item => { - item.value = v - }) - } + // set duration(v) { + // this.options.duration = v + // let canvas = this.getcanvas() + // this.entity.rectangle.material = new Cesium.CustomMaterialSource({ + // image: canvas.toDataURL('image/png'), + // color: this.options.color, + // repeat: new Cesium.Cartesian2(1.0, 1.0), + // duration: this.options.duration / this.options.speed, + // fltr: false, + // is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false + // }) + // this._elms.duration && + // this._elms.duration.forEach(item => { + // item.value = v + // }) + // } get speed() { return this.options.speed } @@ -250,7 +256,7 @@ class GroundText extends Base { image: canvas.toDataURL('image/png'), color: this.options.color, repeat: new Cesium.Cartesian2(1.0, 1.0), - duration: this.options.duration / this.options.speed, + duration: this.duration / this.options.speed, fltr: false, is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false }) @@ -270,7 +276,7 @@ class GroundText extends Base { image: canvas.toDataURL('image/png'), color: this.options.color, repeat: new Cesium.Cartesian2(1.0, 1.0), - duration: this.options.duration / this.options.speed, + duration: this.duration / this.options.speed, fltr: false, is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false }) @@ -328,7 +334,7 @@ class GroundText extends Base { image: canvas.toDataURL('image/png'), color: this.options.color, repeat: new Cesium.Cartesian2(1.0, 1.0), - duration: this.options.duration / this.options.speed, + duration: this.duration / this.options.speed, fltr: false, is2D: this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE2D ? true : false }), @@ -505,6 +511,10 @@ class GroundText extends Base { }) }) } else { + if (this._positionEditingCallback) { + this._positionEditingCallback() + this._positionEditingCallback = null + } if (this.event) { this.event.mouse_move(() => { }) this.event.mouse_left(() => { }) @@ -520,6 +530,11 @@ class GroundText extends Base { return this._positionEditing } + openPositionEditing(cd) { + this.positionEditing = true + this._positionEditingCallback = cd + } + /** * 飞到 */ diff --git a/src/Obj/Base/TextObject/StandText/index.js b/src/Obj/Base/TextObject/StandText/index.js index f424141..07bf83e 100644 --- a/src/Obj/Base/TextObject/StandText/index.js +++ b/src/Obj/Base/TextObject/StandText/index.js @@ -56,13 +56,9 @@ class StandText extends Base { this.options.show = (options.show || options.show === false) ? options.show : true this.nodePoints = [] this.entity - this.options.instruct = options.instruct || "" - this.options.operatingPoint = options.operatingPoint || "" - this.options.attribute = options.attribute || {} - this.options.attribute.link = this.options.attribute.link || {} - this.options.attribute.link.content = this.options.attribute.link.content || [] - this.options.attribute.camera = this.options.attribute.camera || [] - this.options.attributeType = options.attributeType || 'richText' + + delete this.options.name + this.extrudedHeight this._EventBinding = new EventBinding() this.Dialog = _Dialog @@ -71,6 +67,9 @@ class StandText extends Base { StandText.create(this) } + get name() { + return + } get text() { return this.options.text } @@ -297,14 +296,6 @@ class StandText extends Base { // } - get attributeCamera() { - return this.options.attribute.camera - } - - set attributeCamera(v) { - this.options.attribute.camera = v - } - //创建 static async create(that) { @@ -397,15 +388,13 @@ class StandText extends Base { this.Dialog.showCallBack && this.Dialog.showCallBack() }, secondaryEditCallBack: () => { - StandText.nodeEdit(this) + this.nodeEdit() } }) this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' stand-text' let contentElm = document.createElement('div'); contentElm.innerHTML = html(this) this._DialogObject.contentAppChild(contentElm) - this.attributeType = this.options.attributeType - this.attributeCamera = this.options.attribute.camera // setTimeout(() => { // this.attributeLink = this.options.attribute.link.content // this.cameraSelect() @@ -538,23 +527,24 @@ class StandText extends Base { } } - static nodeEdit(that, cb = () => { }) { + nodeEdit(cb = () => { }) { if (YJ.Measure.GetMeasureStatus()) { cb('上一次测量未结束') } else { YJ.Measure.SetMeasureStatus(true) - that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk) - that.event = new MouseEvent(that.sdk) - that.nodePoints = [] + this._nodeEditCallback = cb + this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk) + this.event = new MouseEvent(this.sdk) + this.nodePoints = [] let selectPoint let originalPosition - let positions = that.options.positions + let positions = this.options.positions let fromDegreesArray = [] let minimumHeights = [] let maximumHeights = [] - let width = that.computeDistance2(positions) - let extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0 + let width = this.computeDistance2(positions) + let extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0 for (let i = 0; i < positions.length; i++) { fromDegreesArray.push(positions[i].lng, positions[i].lat) minimumHeights.push(positions[i].alt) @@ -565,55 +555,55 @@ class StandText extends Base { let leftEvent = (movement, cartesian) => { if (selectPoint) { isAdd = true - let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity]) - that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer) - originalPosition = that.options.positions[selectPoint.index] - let entity = that.sdk.viewer.entities.add({ + let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity]) + this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer) + originalPosition = this.options.positions[selectPoint.index] + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', - position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, that.options.positions[selectPoint.index].alt), + position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, this.options.positions[selectPoint.index].alt), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) }, }) - that.nodePoints.splice(selectPoint.index, 0, entity) - that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index]) + this.nodePoints.splice(selectPoint.index, 0, entity) + this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index]) - let positions = that.options.positions + let positions = this.options.positions fromDegreesArray = [] minimumHeights = [] maximumHeights = [] - width = that.computeDistance2(positions) - extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0 + width = this.computeDistance2(positions) + extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0 for (let i = 0; i < positions.length; i++) { fromDegreesArray.push(positions[i].lng, positions[i].lat) minimumHeights.push(positions[i].alt) maximumHeights.push(positions[i].alt + extrudedHeight) } - that.tip.setPosition( + this.tip.setPosition( cartesian, movement.position.x, movement.position.y ) } else { - var pick = that.sdk.viewer.scene.pick(movement.position); + var pick = this.sdk.viewer.scene.pick(movement.position); if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') { selectPoint = pick.id - that.nodePoints.splice(pick.id.index, 1) - that.sdk.viewer.entities.remove(pick.id) - that.tip.set_text('左键开始,右键结束,CTRL+右键撤销') - originalPosition = that.cartesian3Towgs84(cartesian, that.sdk.viewer) - that.entity.wall.positions = new Cesium.CallbackProperty(function () { + this.nodePoints.splice(pick.id.index, 1) + this.sdk.viewer.entities.remove(pick.id) + this.tip.set_text('左键开始,右键结束,CTRL+右键撤销') + originalPosition = this.cartesian3Towgs84(cartesian, this.sdk.viewer) + this.entity.wall.positions = new Cesium.CallbackProperty(function () { return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray) }, false) - that.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () { + this.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () { return maximumHeights }, false) - that.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () { + this.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () { return minimumHeights }, false) } @@ -621,69 +611,69 @@ class StandText extends Base { } let rightEvent = (movement, cartesian) => { if (selectPoint) { - that.options.positions[selectPoint.index] = originalPosition + this.options.positions[selectPoint.index] = originalPosition if(isAdd) { - that.options.positions.splice(selectPoint.index, 1) + this.options.positions.splice(selectPoint.index, 1) } - cb(null, that.options.positions) + cb(null, this.options.positions) } - let positions = that.options.positions + let positions = this.options.positions fromDegreesArray = [] minimumHeights = [] maximumHeights = [] - width = that.computeDistance2(positions) - extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0 + width = this.computeDistance2(positions) + extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0 for (let i = 0; i < positions.length; i++) { fromDegreesArray.push(positions[i].lng, positions[i].lat) minimumHeights.push(positions[i].alt) maximumHeights.push(positions[i].alt + extrudedHeight) } - that.entity.wall.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray) + this.entity.wall.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray) - for (let i = 0; i < that.nodePoints.length; i++) { - that.sdk.viewer.entities.remove(that.nodePoints[i]) + for (let i = 0; i < this.nodePoints.length; i++) { + this.sdk.viewer.entities.remove(this.nodePoints[i]) } - that.nodePoints = [] + this.nodePoints = [] YJ.Measure.SetMeasureStatus(false) - that.event.destroy() - that.tip.destroy() + this.event.destroy() + this.tip.destroy() } - that.event.mouse_left(leftEvent) + this.event.mouse_left(leftEvent) - that.event.mouse_right(rightEvent) + this.event.mouse_right(rightEvent) - that.event.mouse_move((movement, cartesian) => { + this.event.mouse_move((movement, cartesian) => { if (selectPoint) { - let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity]) - that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer) - let positions = that.options.positions + let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity]) + this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer) + let positions = this.options.positions fromDegreesArray = [] minimumHeights = [] maximumHeights = [] - width = that.computeDistance2(positions) - extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0 + width = this.computeDistance2(positions) + extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0 for (let i = 0; i < positions.length; i++) { fromDegreesArray.push(positions[i].lng, positions[i].lat) minimumHeights.push(positions[i].alt) maximumHeights.push(positions[i].alt + extrudedHeight) } } - that.tip.setPosition( + this.tip.setPosition( cartesian, movement.endPosition.x, movement.endPosition.y ) }) - that.event.mouse_right_keyboard_ctrl((movement, cartesian) => { + this.event.mouse_right_keyboard_ctrl((movement, cartesian) => { if (selectPoint) { - that.options.positions.pop() - that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1]) - that.nodePoints.pop() - if (selectPoint.index === that.options.positions.length) { - if (that.nodePoints[selectPoint.index - 1]) { - selectPoint = that.nodePoints[selectPoint.index - 1] + this.options.positions.pop() + this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1]) + this.nodePoints.pop() + if (selectPoint.index === this.options.positions.length) { + if (this.nodePoints[selectPoint.index - 1]) { + selectPoint = this.nodePoints[selectPoint.index - 1] } else { selectPoint.index = 0 @@ -692,7 +682,7 @@ class StandText extends Base { } }) - that.event.gesture_pinck_start((movement, cartesian) => { + this.event.gesture_pinck_start((movement, cartesian) => { let startTime = new Date() let pos = { position: { @@ -700,7 +690,7 @@ class StandText extends Base { y: (movement.position1.y + movement.position2.y) / 2 } } - that.event.gesture_pinck_end(() => { + this.event.gesture_pinck_end(() => { let endTime = new Date() if (endTime - startTime >= 500) { // 长按取消 @@ -712,20 +702,20 @@ class StandText extends Base { }) }) - for (let i = 0; i < that.options.positions.length; i++) { - let entity = that.sdk.viewer.entities.add({ + for (let i = 0; i < this.options.positions.length; i++) { + let entity = this.sdk.viewer.entities.add({ name: 'node-secondary-edit-point', index: i, - position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat, that.options.positions[i].alt), + position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat, this.options.positions[i].alt), billboard: { - image: that.getSourceRootPath() + '/img/point.png', + image: this.getSourceRootPath() + '/img/point.png', width: 15, height: 15, disableDepthTestDistance: Number.POSITIVE_INFINITY, color: Cesium.Color.WHITE.withAlpha(0.99) }, }) - that.nodePoints.push(entity) + this.nodePoints.push(entity) } } } diff --git a/src/Obj/Base/index.js b/src/Obj/Base/index.js index 160fba9..bbbb76e 100644 --- a/src/Obj/Base/index.js +++ b/src/Obj/Base/index.js @@ -15,8 +15,6 @@ import { syncData, getSdk as get2DSdk } from '../../Global/MultiViewportMode' import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../Global/global' class Base extends Tools { - #_showView - #_isShowView constructor(sdk, options = {}) { super(sdk, options); if (!sdk || !sdk.viewer) { @@ -32,8 +30,9 @@ class Base extends Tools { this.rightClickCallBack = null this.picking = true this.options.host = this.options.host || getHost() - // this.#_showView = this.options.showView || 0 + // this._showView = this.options.showView || 0 this.setDefaultValue() + this._showView // this.sdk.addIncetance(this.options.id, this) } @@ -60,7 +59,7 @@ class Base extends Tools { // } get showView() { - return this.#_showView + return this._showView } set showView(v) { @@ -68,28 +67,28 @@ class Base extends Tools { let sdk2D = get2DSdk().sdkD if (!sdk2D) { - this.#_showView = v + this._showView = v if (this.entity) { this.entity._showView = v } return } if (this.sdk === sdk2D) { - this.#_showView = 0 + this._showView = 0 return } - if (!this.#_showView && !this.show) { + if (!this._showView && !this.show) { return } if (this.sdk === sdk2D) { - this.#_showView = 0 + this._showView = 0 return } if (v != 2 && v != 3) { - this.#_showView = 0 + this._showView = 0 } else { - this.#_showView = v + this._showView = v } this.isShowView = true @@ -98,7 +97,7 @@ class Base extends Tools { // return // } - if (!this.#_showView) { + if (!this._showView) { this.show = true } else { diff --git a/src/Obj/Element/Dialog/eventBinding.js b/src/Obj/Element/Dialog/eventBinding.js index c47327f..8b48d56 100644 --- a/src/Obj/Element/Dialog/eventBinding.js +++ b/src/Obj/Element/Dialog/eventBinding.js @@ -17,6 +17,7 @@ class EventBinding { } on(that, elements) { + return this.element = {} for (let i = 0; i < elements.length; i++) { if (!elements[i] || !elements[i].attributes) { diff --git a/src/Tools/index.js b/src/Tools/index.js index c5b2466..f143bf9 100644 --- a/src/Tools/index.js +++ b/src/Tools/index.js @@ -127,9 +127,9 @@ class Tools { var alt = cartographic.height < 0 ? 0 : cartographic.height // var alt = cartographic.height return { - lng: lng, - lat: lat, - alt: alt, + lng: Number(lng.toFixed(8)), + lat: Number(lat.toFixed(8)), + alt: Number(alt.toFixed(2)), } } @@ -141,13 +141,14 @@ class Tools { * @param [fractionDigits=2] 保留小数点位数 * @param [ground=true] 是否贴地 * */ - async computeDistance(positions = [], fractionDigits = 2, type = '空间长度') { + async computeDistance(positions = [], fractionDigits = 2, type = 0) { if (positions.length < 2) { return 0 } else { let length = 0 switch (type) { - case '空间长度': + case '0': + case 0: for (let i = 0; i < positions.length - 1; i++) { const position1 = Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, positions[i].alt); const position2 = Cesium.Cartesian3.fromDegrees(positions[i + 1].lng, positions[i + 1].lat, positions[i + 1].alt); @@ -155,7 +156,8 @@ class Tools { length = length + distance } break - case '投影长度': + case '1': + case 1: for (let i = 0; i < positions.length - 1; i++) { const position1 = Cesium.Cartesian3.fromDegrees(positions[i].lng, positions[i].lat, 0); const position2 = Cesium.Cartesian3.fromDegrees(positions[i + 1].lng, positions[i + 1].lat, 0); @@ -163,7 +165,8 @@ class Tools { length = length + distance } break - case '地表长度': + case '2': + case 2: let meters let lineString2 = [] positions.forEach((item) => { @@ -1243,14 +1246,28 @@ class Tools { * */ deepCopyObj(obj) { let newobj = null; - //判断是否需要继续进行递归 - if (typeof (obj) == 'object' && obj !== null) { - newobj = obj instanceof Array ? [] : {}; //进行下一层递归克隆 + // 处理数组 - 使用原生Array构造函数创建新数组 + if (Array.isArray(obj)) { + newobj = []; + // 只拷贝数组元素,不拷贝可能存在的扩展方法 + for (let i = 0; i < obj.length; i++) { + newobj[i] = this.deepCopyObj(obj[i]); + } + return newobj; + } + + // 处理对象 + else if (obj && typeof obj === 'object') { + newobj = {}; for (let i in obj) { - if (i != 'earth' && i != 'Dialog') - newobj[i] = this.deepCopyObj(obj[i]) - } //如果不是对象直接赋值 - } else newobj = obj; + // 排除指定属性和方法属性 + if (i !== 'earth' && i !== 'Dialog' && typeof obj[i] !== 'function') { + newobj[i] = this.deepCopyObj(obj[i]); + } + } + return newobj; + } + else newobj = obj; return newobj; } diff --git a/static/custom/css/index.css b/static/custom/css/index.css index a1ffab6..cc237ac 100644 --- a/static/custom/css/index.css +++ b/static/custom/css/index.css @@ -65,7 +65,7 @@ position: absolute; color: var(--color-sdk-auxiliary-public); font-size: 14px; - z-index: 999999; + z-index: 99; background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); border: 1.5px solid; border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; @@ -76,8 +76,6 @@ } .YJ-custom-base-dialog * { - margin: 0px; - padding: 0px; box-sizing: border-box; } @@ -171,7 +169,7 @@ position: relative; } -.YJ-custom-base-dialog button:not(button[disabled="disabled"]):hover { +.YJ-custom-base-dialog button:not(button[disabled]):hover { border-color: rgba(var(--color-sdk-base-rgb), 1) !important; cursor: pointer; } @@ -2214,6 +2212,34 @@ .YJ-custom-base-dialog.cut-fill>.content>div .div-item:last-child .row .unit { margin-left: 5px; } +.YJ-custom-base-dialog.cut-fill>.content>div .el-slider__button { + width: 16px; + height: 16px; + border: 2px solid rgba(var(--color-sdk-base-rgb), 1); +} +.YJ-custom-base-dialog.cut-fill>.content>div .el-slider__bar { + background-color: rgba(var(--color-sdk-base-rgb), 1); +} +.YJ-custom-base-dialog.cut-fill>.content>div .firstTip { + font-size: 14px; + font-weight: 700; + letter-spacing: 0px; + line-height: 0px; + color: rgba(255, 255, 255, 1); + position: absolute; + top: 157px; + left: 340px; +} +.YJ-custom-base-dialog.cut-fill>.content>div .endTip { + font-size: 14px; + font-weight: 700; + letter-spacing: 0px; + line-height: 0px; + color: rgba(255, 255, 255, 1); + position: absolute; + top: 157px; + left: 515px; +} /* 淹没分析 */ .YJ-custom-base-dialog.submerge>.content>div .row>.col { @@ -2417,6 +2443,41 @@ .YJ-custom-base-dialog.circle-view-shed>.content { width: 290px; } +.YJ-custom-base-dialog.circle-view-shed>.content>div .el-slider__button { + width: 16px; + height: 16px; + border: 2px solid rgba(var(--color-sdk-base-rgb), 1); +} + +.YJ-custom-base-dialog.circle-view-shed>.content>div .el-slider__bar { + background-color: rgba(var(--color-sdk-base-rgb), 1); +} + +.YJ-custom-base-dialog.circle-view-shed>.content>div .firstTip { + font-size: 14px; + font-weight: 700; + letter-spacing: 0px; + line-height: 0px; + color: rgba(255, 255, 255, 1); + position: absolute; + top: 150px; + left: 88px; +} + +.YJ-custom-base-dialog.circle-view-shed>.content>div .endTip { + font-size: 14px; + font-weight: 700; + letter-spacing: 0px; + line-height: 0px; + color: rgba(255, 255, 255, 1); + position: absolute; + top: 150px; + left: 240px; +} +.el-popper.is-dark { + z-index: 100000000 !important; + /* 确保这个值足够高 */ +} /* 地形可视域分析 */ .YJ-custom-base-dialog.visibility>.content { @@ -3828,3 +3889,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%; +}