Files
sdk4.0/src/Obj/Base/CurvelineObject/index.js
2025-08-22 21:55:50 +08:00

3296 lines
113 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @description 线
*/
import Dialog from '../../Element/Dialog'
import { html } from './_element'
import Base from '../index'
import cy_tabs from '../../Element/cy_html_tabs'
import richText from '../../Element/richText'
import EventBinding from './eventBinding'
import LabelObject from '../LabelObject'
import MouseEvent from '../../../Event/index'
import MouseTip from '../../../MouseTip'
import Controller from '../../../Controller/index'
import { syncData, get3DView } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist'
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
class CurvelineObject extends Base {
/**
* @constructor
* @param sdk
* @description 折线
* @param options {object} 线属性
* @param options.name{string} 名称
* @param options.width=3{number} 线宽
* @param options.color=#ff0000 {string} 颜色
* @param options.type=0 {number} 材质类型 0-实线 1-虚线 2-泛光
* @param options.heightMode{number} 高度模式0海拔高度1相对高度2依附模式
* @param options['nose-to-tail']=false {boolean} 首尾相连
* @param options.extend=false {boolean} 线缓冲
* @param options['extend-width']=10 {number} 线缓冲宽度
* @param options['extend-color']=#ffde00 {number} 线缓冲颜色
* @param options.show=true {boolean} 显隐
* @param {Array.<object>} options.positions 坐标数组 [{lng,lat},...]
* @param options.label {object} 标注
* @param options.label.show=false {boolean} 标注显隐
* @param options.label.fontSize=20 {number} 标注字体大小
* @param options.label.color=#ffffff {string} 标注字体颜色
* @param options.label.lineWidth=1 {number} 标注引线宽
* @param options.label.pixelOffset=20 {string} 标注引线长度
* @param options.label.backgroundColor=['#42c6ef', '#42c6ef'] {Array} 标注背景
* @param options.label.lineColor=#fff000 {string} 标注引线颜色
* @param options.label.scaleByDistance=false {boolean} 标注是否随视野缩放
* @param options.label.near=2000 {boolean} 标注随视野缩放最近距离
* @param options.label.far=100000 {boolean} 标注随视野缩放最远距离
* @param _Dialog {object} 弹框事件
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
* */
constructor(sdk, options = {}, _Dialog = {}) {
super(sdk, options)
this.options.name = options.name || '未命名对象'
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.extend = options.extend || false
this.options.rotate = 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']
: 10
this.options['extend-color'] = options['extend-color'] || '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
this._elms = []
options.label = options.label || {}
this.options.label = {
text: this.options.name,
show: options.label.show || false,
position: options.label.position,
fontSize:
options.label.fontSize || options.label.fontSize === 0
? options.label.fontSize
: 20,
fontFamily: options.label.fontFamily ? options.label.fontFamily : 0,
color: options.label.color || '#ffffff',
lineWidth:
options.label.lineWidth || options.label.lineWidth === 0
? options.label.lineWidth
: 4,
pixelOffset:
options.label.pixelOffset || options.label.pixelOffset === 0
? options.label.pixelOffset
: 20,
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
lineColor: options.label.lineColor || '#00ffff80',
scaleByDistance: options.label.scaleByDistance || false,
near:
options.label.near || options.label.near === 0
? options.label.near
: 2000,
far:
options.label.far || options.label.far === 0
? 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.operate = {}
this.nodePoints = []
this.unitNum = 0
this.inputSpeed = (options.speed && Math.pow(options.speed, -1) * 100) || 10
this.Dialog = _Dialog
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++) {
this.options.positions[i].lng = Number(Number(this.options.positions[i].lng).toFixed(8))
this.options.positions[i].lat = Number(Number(this.options.positions[i].lat).toFixed(8))
this.options.positions[i].alt = Number(Number(this.options.positions[i].alt).toFixed(2))
}
this.sdk.addIncetance(this.options.id, this)
CurvelineObject.create(this)
}
}
get color() {
return this.options.color
}
set color(v) {
this.options.color = v || '#ff0000'
// this.entity.polyline.material = this.getMaterial(v, this.options.type)
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)
if (this._elms.color) {
this._elms.color.forEach((item, i) => {
let colorPicker = new YJColorPicker({
el: item.el,
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.options.color,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: c => {
this.color = c
}, //点击确认按钮事件回调
clear: () => {
this.color = 'rgba(255,0,0,1)'
} //点击清空按钮事件回调
})
this._elms.color[i] = colorPicker
})
}
}
get speed() {
return this.options.speed
}
set speed(v) {
this.options.speed = v
// this.options.speed = v !== 0 ? Math.pow(v, -1) * 100 : 0
this.inputSpeed = v !== 0 ? Math.pow(v, -1) * 100 : 0
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 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)
}
get rotate() {
return this.options.rotate
}
set rotate(v) {
this.options.rotate = v
CurvelineObject.closeNodeEdit(this)
this._elms.rotate &&
this._elms.rotate.forEach(item => {
item.checked = v
})
this.options.rotate = v
this.entity.polyline.material = this.getMaterial(this.options.color, this.options.type, this.entity, this.options)
}
get space() {
return this.options.space
}
set space(v) {
this.options.space = 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 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']
}
set wordsName(v) {
this.options['words-name'] = v
this._elms.wordsName &&
this._elms.wordsName.forEach(item => {
item.value = v
})
let _this = this
if (!this.noseToTail) {
this.computeDistance(
this.smoothHandle(this.options.positions),
2,
v
).then(res => {
_this.options.lengthByMeter = res
_this.lengthUnit = this.options['length-unit']
})
} 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 lineWidth() {
return this.options.width
}
set lineWidth(v) {
this.options.width = (v || v == 0) ? v : 3
this._elms.lineWidth &&
this._elms.lineWidth.forEach(item => {
item.value = this.options.width
})
this.entity &&
this.entity.polyline &&
(this.entity.polyline.width = this.options.width)
}
get lineType() {
return this.options.type
}
set lineType(v) {
let lineTypeData = [
{
name: '<i class="icon line"></i>实线',
value: '实线',
key: 0,
icon: 'line'
},
{
name: '<i class="icon dash-line"></i>虚线',
value: '虚线',
key: 1,
icon: 'dash-line'
},
{
name: '<i class="icon light-line"></i>泛光',
value: '泛光',
key: 2,
icon: 'light-line'
},
{
name: '<i class="icon tail-line"></i>尾迹光线',
value: '尾迹光线',
key: 3,
icon: 'tail-line'
},
{
name: '<i class="icon mult-tail-line"></i>多尾迹光线',
value: '多尾迹光线',
key: 4,
icon: 'mult-tail-line'
},
{
name: '<i class="icon flow-dash-line1"></i>流动虚线1',
value: '流动虚线1',
key: 5,
icon: 'flow-dash-line1'
},
{
name: '<i class="icon flow-dash-line2"></i>流动虚线2',
value: '流动虚线2',
key: 6,
icon: 'flow-dash-line2'
},
{
name: '<i class="icon pic-line1"></i>流动箭头1',
value: '流动箭头1',
key: 7,
icon: 'pic-line1'
},
{
name: '<i class="icon pic-line2"></i>流动箭头2',
value: '流动箭头2',
key: 8,
icon: 'pic-line2'
},
{
name: '<i class="icon pic-line3"></i>流动箭头3',
value: '流动箭头3',
key: 9,
icon: 'pic-line3'
},
{
name: '<i class="icon pic-line4"></i>流动箭头4',
value: '流动箭头4',
key: 10,
icon: 'pic-line4'
},
{
name: '<i class="icon pic-line5"></i>流动箭头5',
value: '流动箭头5',
key: 11,
icon: 'pic-line5'
},
{
name: '<i class="icon pic-line6"></i>流动箭头6',
value: '流动箭头6',
key: 12,
icon: 'pic-line6'
}
]
this.options.type = Number(v)
for (let i = 0; i < lineTypeData.length; i++) {
if (lineTypeData[i].key === Number(v)) {
this._elms.lineType &&
this._elms.lineType.forEach(item => {
item.value = lineTypeData[i].value
if (2 < item.value && item.value < 13) {//贴图参数
document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex')
} else {
document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none')
}
if (2 < item.value && item.value < 5) {//尾迹参数
document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'none')
document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'none')
} else {
document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'flex')
document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'flex')
}
})
break
}
}
let params = { ...this.options }
params.speed = this.inputSpeed
this.entity &&
this.entity.polyline &&
(this.entity.polyline.material = this.getMaterial(
this.options.color,
this.options.type,
this.entity,
params
))
}
get noseToTail() {
return this.options['nose-to-tail']
}
set noseToTail(v) {
this.options['nose-to-tail'] = v
CurvelineObject.closeNodeEdit(this)
this._elms.noseToTail &&
this._elms.noseToTail.forEach(item => {
item.checked = v
})
if (this.entity) {
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
fromDegreesArray
)
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]
// dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
// } else {
// let dom = document.getElementsByClassName('input-select-unit')[1]
// dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
// }
// } else {
// if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) {
// let dom = document.getElementsByClassName('input-select-unit')[1]
// dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
// } else {
// let dom = document.getElementsByClassName('input-select-unit')[1]
// dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
// }
// }
}
get heightMode() {
return this.options.heightMode ? this.options.heightMode : 0
}
set heightMode(v) {
this.positionEditing = false
this.options.heightMode = (v || v == 0) ? v : 2
let heightModeName = ''
CurvelineObject.closeNodeEdit(this)
let ground = false
let disabled = false
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
fromDegreesArray
)
this.renewPolygon(fromDegreesArray)
switch (this.options.heightMode) {
case '0':
case 0:
this.entity.polyline.clampToGround = ground
this.extend = false
heightModeName = '海拔高度'
break
case '1':
case 1:
this.entity.polyline.clampToGround = ground
this.extend = false
heightModeName = '相对地表'
break
case '2':
case 2:
ground = true
disabled = true
this.entity.polyline.clampToGround = ground
heightModeName = '依附模型'
break
}
// this.options.lengthByMeter = this.computeDistance2(
// this.smoothHandle(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) {
this.label.ground = ground
this._elms.heightMode && (this._elms.heightMode.value = '依附模型')
this.label.position = [
this.options.positions[0].lng,
this.options.positions[0].lat
]
}
else {
this.label.ground = ground
this.label.position = [
this.options.positions[0].lng,
this.options.positions[0].lat,
fromDegreesArray[2]
]
this.options.label.position = {
lng: this.options.positions[0].lng,
lat: this.options.positions[0].lat,
alt: fromDegreesArray[2]
}
}
}, 0);
}
get extend() {
return this.options.extend
}
set extend(v) {
this.options.extend = v
CurvelineObject.closeNodeEdit(this)
if (v) {
this.heightMode = 2
}
this._elms.extend &&
this._elms.extend.forEach(item => {
item.checked = v
})
if (this.entity) {
if (this.options.extend) {
let fromDegreesArray = this.renewPositions(this.options.positions)
this.renewPolygon(fromDegreesArray)
} else {
this.entity.polygon = undefined
}
}
}
get extendWidth() {
return this.options['extend-width']
}
set extendWidth(v) {
this.options['extend-width'] = v
this._elms.extendWidth &&
this._elms.extendWidth.forEach(item => {
item.value = v
})
let fromDegreesArray = this.renewPositions(this.options.positions)
this.renewPolygon(fromDegreesArray)
}
get extendColor() {
return this.options['extend-color']
}
set extendColor(v) {
this.options['extend-color'] = v
if (this._elms.extendColor) {
this._elms.extendColor.forEach((item, i) => {
let extendColorPicker = new YJColorPicker({
el: item.el,
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.extendColor,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.extendColor = color
}, //点击确认按钮事件回调
clear: () => {
this.extendColor = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
this._elms.extendColor[i] = extendColorPicker
})
}
this.entity &&
this.entity.polygon &&
(this.entity.polygon.material = Cesium.Color.fromCssColorString(
this.options['extend-color']
))
}
get labelShow() {
return this.options.label.show
}
set labelShow(v) {
this.options.label.show = v
if (this.show && !this.showView || this.showView == 3) {
this.label.show = v
setTimeout(() => {
this.label.position = [
this.options.positions[0].lng,
this.options.positions[0].lat,
this.options.positions[0].alt
]
}, 0)
} else {
this.label.show = false
}
this._elms.labelShow &&
this._elms.labelShow.forEach(item => {
item.checked = v
})
}
get labelFontFamily() {
return this.options.label.fontFamily
}
set labelFontFamily(v) {
this.options.label.fontFamily = v || 0
this.label && (this.label.fontFamily = this.options.label.fontFamily)
let name = getFontFamilyName(this.labelFontFamily) || ''
this._elms.labelFontFamily &&
this._elms.labelFontFamily.forEach(item => {
item.value = name
})
}
get labelColor() {
return this.options.label.color
}
set labelColor(v) {
this.options.label.color = v
this.label.color = v
if (this._elms.labelColor) {
this._elms.labelColor.forEach((item, i) => {
let labelColorPicker = new YJColorPicker({
el: item.el,
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.labelColor,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.labelColor = color
}, //点击确认按钮事件回调
clear: () => {
this.labelColor = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
this._elms.labelColor[i] = labelColorPicker
})
}
}
get labelFontSize() {
return this.options.label.fontSize
}
set labelFontSize(v) {
this.options.label.fontSize = v
this.label.fontSize = v
this._elms.labelFontSize &&
this._elms.labelFontSize.forEach(item => {
item.value = v
})
}
get labelScaleByDistance() {
return this.options.label.scaleByDistance
}
set labelScaleByDistance(v) {
this.options.label.scaleByDistance = v
this.label.scaleByDistance = v
this._elms.labelScaleByDistance &&
this._elms.labelScaleByDistance.forEach(item => {
item.checked = v
})
}
get labelNear() {
return this.options.label.near
}
set labelNear(v) {
let near = v
if (near > this.labelFar) {
near = this.labelFar
}
this.options.label.near = near
this.label.near = near
this._elms.labelNear && this._elms.labelNear.forEach((item) => {
item.value = near
})
}
get labelFar() {
return this.options.label.far
}
set labelFar(v) {
let far = v
if (far < this.labelNear) {
far = this.labelNear
}
this.options.label.far = far
this.label.far = far
this._elms.labelFar && this._elms.labelFar.forEach((item) => {
item.value = far
})
}
get labelLineWidth() {
return this.options.label.lineWidth
}
set labelLineWidth(v) {
this.options.label.lineWidth = v
this.label.lineWidth = v
this._elms.labelLineWidth &&
this._elms.labelLineWidth.forEach(item => {
item.value = v
})
}
get labelPixelOffset() {
return this.options.label.pixelOffset
}
set labelPixelOffset(v) {
this.options.label.pixelOffset = v
this.label.pixelOffset = v
this._elms.labelPixelOffset &&
this._elms.labelPixelOffset.forEach(item => {
item.value = v
})
}
get labelLineColor() {
return this.options.label.lineColor
}
set labelLineColor(v) {
this.options.label.lineColor = v
this.label.lineColor = v
if (this._elms.labelLineColor) {
this._elms.labelLineColor.forEach((item, i) => {
let lineColorPicker = new YJColorPicker({
el: item.el,
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.labelLineColor,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.labelLineColor = color
}, //点击确认按钮事件回调
clear: () => {
this.labelLineColor = 'rgba(0,255,255,0.5)'
} //点击清空按钮事件回调
})
this._elms.labelLineColor[i] = lineColorPicker
})
}
}
get labelBackgroundColorStart() {
return this.options.label.backgroundColor[0]
}
set labelBackgroundColorStart(v) {
this.options.label.backgroundColor[0] = v
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
if (this._elms.labelBackgroundColorStart) {
this._elms.labelBackgroundColorStart.forEach((item, i) => {
let labelBackgroundColorStartPicker = new YJColorPicker({
el: item.el,
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.labelBackgroundColorStart,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.labelBackgroundColorStart = color
}, //点击确认按钮事件回调
clear: () => {
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
this._elms.labelBackgroundColorStart[
i
] = labelBackgroundColorStartPicker
})
}
}
get labelBackgroundColorEnd() {
return this.options.label.backgroundColor[1]
}
set labelBackgroundColorEnd(v) {
this.options.label.backgroundColor[1] = v
this.label.backgroundColor = [this.label.backgroundColor[0], v]
if (this._elms.labelBackgroundColorEnd) {
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
let labelBackgroundColorEndPicker = new YJColorPicker({
el: item.el,
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.labelBackgroundColorEnd,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.labelBackgroundColorEnd = color
}, //点击确认按钮事件回调
clear: () => {
this.labelBackgroundColorEnd = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
this._elms.labelBackgroundColorEnd[i] = labelBackgroundColorEndPicker
})
}
}
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
}
set attributeLink(v) {
this.options.attribute.link.content = v
if (
!this._DialogObject ||
!this._DialogObject._element ||
!this._DialogObject._element.content ||
this._DialogObject._element.content.getElementsByClassName(
'attribute-content-link'
).length == 0
) {
return
}
let table = this._DialogObject._element.content
.getElementsByClassName('attribute-content-link')[1]
.getElementsByClassName('table')[0]
let tableContent = table.getElementsByClassName('table-body')[0]
tableContent.innerHTML = ''
if (this.options.attribute.link.content.length > 0) {
table.getElementsByClassName('table-empty')[0].style.display = 'none'
} else {
table.getElementsByClassName('table-empty')[0].style.display = 'flex'
}
for (let i = 0; i < this.options.attribute.link.content.length; i++) {
let tr =
`
<div class="tr">
<div class="td">` +
this.options.attribute.link.content[i].name +
`</div>
<div class="td">` +
this.options.attribute.link.content[i].url +
`</div>
<div class="td">
<button @click="linkEdit">编辑</button>
<button @click="linkDelete">删除</button>
</div>
</div>`
let trElm = document.createRange().createContextualFragment(tr)
tableContent.appendChild(trElm)
}
let item = tableContent.getElementsByClassName('tr')
let fun = {
linkEdit: async index => {
this.attributeLink = await this.options.attribute.link.content
let table = this._DialogObject._element.content
.getElementsByClassName('attribute-content-link')[1]
.getElementsByClassName('table')[0]
let tableContent = table.getElementsByClassName('table-body')[0]
let item = tableContent.getElementsByClassName('tr')
for (let i = 0; i < item.length; i++) {
if (index === i) {
let height = item[i].offsetHeight
let html = `
<div class="td">
<input class="input" type="text">
</div>
<div class="td">
<textarea class="input link-edit" type="text"></textarea>
</div>
<div class="td">
<button @click="confirmEdit">确认</button>
<button @click="cancelEdit">取消</button>
</div>`
item[i].innerHTML = html
let textareaElm = item[i].getElementsByClassName('link-edit')[0]
textareaElm.style.height = height - 10 + 'px'
let td = item[i].getElementsByClassName('td')
td[0].getElementsByClassName(
'input'
)[0].value = this.options.attribute.link.content[index].name
td[1].getElementsByClassName(
'input'
)[0].value = this.options.attribute.link.content[index].url
let btn = item[i].getElementsByTagName('button')
for (let n = 0; n < btn.length; n++) {
if (!btn[n] || !btn[n].attributes) {
continue
}
for (let m of btn[n].attributes) {
if (m.name === '@click') {
btn[n].addEventListener('click', e => {
if (typeof fun[m.value] === 'function') {
fun[m.value](
{
name: td[0].getElementsByClassName('input')[0].value,
url: td[1].getElementsByClassName('input')[0].value
},
i
)
}
})
btn[n].attributes.removeNamedItem(m.name)
break
}
}
}
break
}
}
},
linkDelete: i => {
this.options.attribute.link.content.splice(i, 1)
this.attributeLink = this.options.attribute.link.content
},
confirmEdit: (value, i) => {
let name = value.name && value.name.replace(/\s/g, '')
let url = value.url && value.url.replace(/\s/g, '')
if (name && url) {
this.options.attribute.link.content[i] = value
} else {
window.ELEMENT &&
window.ELEMENT.Message({
message: '名称或链接不能为空!',
type: 'warning',
duration: 1500
})
}
this.attributeLink = this.options.attribute.link.content
},
cancelEdit: () => {
this.attributeLink = this.options.attribute.link.content
},
fileSelect: (value, i) => {
let fileElm = item[i].getElementsByClassName('file-select')[0]
fileElm.click()
fileElm.removeEventListener('change', fileSelect)
fileElm.addEventListener('change', fileSelect)
}
}
let fileSelect = event => {
if (event.target.value) {
let td = item[
event.target.getAttribute('index')
].getElementsByClassName('td')
td[1].getElementsByClassName('input')[0].value = event.target.value
event.target.value = null
}
}
for (let i = 0; i < item.length; i++) {
let btn = item[i].getElementsByTagName('button')
for (let n = 0; n < btn.length; n++) {
if (!btn[n] || !btn[n].attributes) {
continue
}
for (let m of btn[n].attributes) {
if (m.name === '@click') {
btn[n].addEventListener('click', e => {
if (typeof fun[m.value] === 'function') {
fun[m.value](i)
}
})
btn[n].attributes.removeNamedItem(m.name)
break
}
}
}
}
}
get attributeCamera() {
return this.options.attribute.camera.content
}
set attributeCamera(v) {
this.options.attribute.camera.content = v
}
get attributeVr() {
return this.options.attribute.vr.content
}
set attributeVr(v) {
this.options.attribute.vr.content = v
if (
!this._DialogObject ||
!this._DialogObject._element ||
!this._DialogObject._element.content ||
this._DialogObject._element.content.getElementsByClassName(
'attribute-content-vr'
).length == 0
) {
return
}
let table = this._DialogObject._element.content
.getElementsByClassName('attribute-content-vr')[1]
.getElementsByClassName('table')[0]
let tableContent = table.getElementsByClassName('table-body')[0]
tableContent.innerHTML = ''
if (this.options.attribute.vr.content.length > 0) {
table.getElementsByClassName('table-empty')[0].style.display = 'none'
} else {
table.getElementsByClassName('table-empty')[0].style.display = 'flex'
}
for (let i = 0; i < this.options.attribute.vr.content.length; i++) {
let tr =
`
<div class="tr">
<div class="td">` +
this.options.attribute.vr.content[i].name +
`</div>
<div class="td">` +
this.options.attribute.vr.content[i].url +
`</div>
<div class="td">
<button @click="vrEdit">编辑</button>
<button @click="vrDelete">删除</button>
</div>
</div>`
let trElm = document.createRange().createContextualFragment(tr)
tableContent.appendChild(trElm)
}
let item = tableContent.getElementsByClassName('tr')
let fun = {
vrEdit: async index => {
this.attributeVr = await this.options.attribute.vr.content
let table = this._DialogObject._element.content
.getElementsByClassName('attribute-content-vr')[1]
.getElementsByClassName('table')[0]
let tableContent = table.getElementsByClassName('table-body')[0]
let item = tableContent.getElementsByClassName('tr')
for (let i = 0; i < item.length; i++) {
if (index === i) {
let height = item[i].offsetHeight
let html = `
<div class="td">
<input class="input" type="text">
</div>
<div class="td">
<textarea class="input link-edit" type="text"></textarea>
</div>
<div class="td">
<button @click="confirmEdit">确认</button>
<button @click="cancelEdit">取消</button>
</div>`
item[i].innerHTML = html
let textareaElm = item[i].getElementsByClassName('link-edit')[0]
textareaElm.style.height = height - 10 + 'px'
let td = item[i].getElementsByClassName('td')
td[0].getElementsByClassName(
'input'
)[0].value = this.options.attribute.vr.content[index].name
td[1].getElementsByClassName(
'input'
)[0].value = this.options.attribute.vr.content[index].url
let btn = item[i].getElementsByTagName('button')
for (let n = 0; n < btn.length; n++) {
if (!btn[n] || !btn[n].attributes) {
continue
}
for (let m of btn[n].attributes) {
if (m.name === '@click') {
btn[n].addEventListener('click', e => {
if (typeof fun[m.value] === 'function') {
fun[m.value](
{
name: td[0].getElementsByClassName('input')[0].value,
url: td[1].getElementsByClassName('input')[0].value
},
i
)
}
})
btn[n].attributes.removeNamedItem(m.name)
break
}
}
}
break
}
}
},
vrDelete: i => {
this.options.attribute.vr.content.splice(i, 1)
this.attributeVr = this.options.attribute.vr.content
},
confirmEdit: (value, i) => {
let name = value.name && value.name.replace(/\s/g, '')
let url = value.url && value.url.replace(/\s/g, '')
if (name && url) {
this.options.attribute.vr.content[i] = value
} else {
window.ELEMENT &&
window.ELEMENT.Message({
message: '名称或链接不能为空!',
type: 'warning',
duration: 1500
})
}
this.attributeVr = this.options.attribute.vr.content
},
cancelEdit: () => {
this.attributeVr = this.options.attribute.vr.content
},
fileSelect: (value, i) => {
let fileElm = item[i].getElementsByClassName('file-select')[0]
fileElm.click()
fileElm.removeEventListener('change', fileSelect)
fileElm.addEventListener('change', fileSelect)
}
}
let fileSelect = event => {
if (event.target.value) {
let td = item[
event.target.getAttribute('index')
].getElementsByClassName('td')
td[1].getElementsByClassName('input')[0].value = event.target.value
event.target.value = null
}
}
for (let i = 0; i < item.length; i++) {
let btn = item[i].getElementsByTagName('button')
for (let n = 0; n < btn.length; n++) {
if (!btn[n] || !btn[n].attributes) {
continue
}
for (let m of btn[n].attributes) {
if (m.name === '@click') {
btn[n].addEventListener('click', e => {
if (typeof fun[m.value] === 'function') {
fun[m.value](i)
}
})
btn[n].attributes.removeNamedItem(m.name)
break
}
}
}
}
}
get attributeGoods() {
return this.options.attribute.goods.content
}
set attributeGoods(v) {
this.options.attribute.goods.content = v
}
static async createLabel(that) {
let height
let ground
let objectsToExclude = [...that.sdk.viewer.entities.values]
switch (that.options.heightMode) {
case '0':
case 0:
ground = false
height = that.options.positions[0].alt
break
case '1':
case 1:
ground = false
height = await that.getClampToHeight({
lng: that.options.positions[0].lng,
lat: that.options.positions[0].lat
}, objectsToExclude) + that.options.positions[0].alt
break
case '2':
case 2:
ground = true
height = await that.getClampToHeight({
lng: that.options.positions[0].lng,
lat: that.options.positions[0].lat
}, objectsToExclude)
break
}
if (!that.options.label.position) {
that.options.label.position = {
lng: that.options.positions[0].lng,
lat: that.options.positions[0].lat,
alt: height
}
}
that.label = new LabelObject(that.sdk, {
id: that.options.id,
show: that.options.show ? that.options.label.show : false,
position: [
that.options.label.position.lng,
that.options.label.position.lat,
that.options.label.position.alt
],
text: that.options.name,
fontSize: that.options.label.fontSize,
fontFamily: that.options.label.fontFamily,
color: that.options.label.color,
pixelOffset: that.options.label.pixelOffset,
backgroundColor: that.options.label.backgroundColor,
lineColor: that.options.label.lineColor,
lineWidth: that.options.label.lineWidth,
scaleByDistance: that.options.label.scaleByDistance,
near: that.options.label.near,
far: that.options.label.far,
ground: ground
})
}
static create(that) {
let ground
if (that.heightMode == 2) {
ground = true
} else {
ground = false
}
let positions = that.options.positions
let fromDegreesArray = that.renewPositions(positions)
that.entity = that.sdk.viewer.entities.add({
id: that.options.id,
show: that.options.show,
polyline: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray),
width: that.options.width,
clampToGround: ground,
// material: that.getMaterial(that.options.color, that.options.type),
zIndex: that.sdk._entityZIndex
}
})
that.entity.polyline.oriWidth = that.options.width
that.judgeLine(that.entity, that.options)
let params = { ...that.options }
params.speed = that.inputSpeed
that.entity.polyline.material = that.getMaterial(
that.options.color,
that.options.type,
that.entity,
params
)
that.sdk._entityZIndex++
CurvelineObject.createLabel(that)
// that.entity.polyline.positionsLngLat = positions
that.renewPolygon(fromDegreesArray)
// that.options.lengthByMeter = that.computeDistance2(that.smoothHandle(positions), 2, ground)
// that.lengthUnit = that.options['length-unit']
// syncData(that.sdk, that.options.id)
// if (that.options.show) {
// setSplitDirection(0, that.options.id)
// }
that.computeDistance(
that.smoothHandle(positions),
2,
that.options['words-name']
).then(res => {
that.options.lengthByMeter = res
that.lengthUnit = that.options['length-unit']
syncData(that.sdk, that.options.id)
if (that.options.show) {
setSplitDirection(0, that.options.id)
}
})
// if (this.options['nose-to-tail']) {
// let array = []
// for (let i = 0; i < fromDegreesArray.length; i += 2) {
// array.push({ lng: fromDegreesArray[i], lat: fromDegreesArray[i + 1] })
// }
// this.options.fit_length = tool.computeDistance2(array)
// }
// else {
// this.options.fit_length = tool.computeDistance2(positions)
// }
// if (this.options.fit_length_unit === 'km') {
// this.options.fit_length = this.options.fit_length / 1000
// }
let scene = that.sdk.viewer.scene
}
judgeLine(entity, newParam) {
if (!entity.polyline.oriRepeat) {
let param = {
color: newParam.color,
image: this.getSourceRootPath() + `/img/arrow/1.png`,
space: newParam.space,
speed: newParam.speed
}
param.speed = newParam.rotate ? param.speed : 0 - param.speed
const canvasEle = document.createElement('canvas');
const ctx = canvasEle.getContext('2d')
const myImg = new Image()
// myImg.src = that.getSourceRootPath() + '/img/arrow/1.png'
myImg.src = param.image
let that = this
myImg.onload = function () {
canvasEle.width = myImg.width * (param.space + 1)
canvasEle.height = myImg.height
let oriRepeat = that.getSceenLine(entity, param, canvasEle)
oriRepeat && (entity.polyline.oriRepeat = oriRepeat)
var positionProperty = entity.polyline.positions;
var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
if (!Cesium.defined(positions)) {
return new Cesium.Cartesian2(1.0, 1.0);
// return 1.0;
}
var distance = 0;
for (var i = 0; i < positions.length - 1; ++i) {
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
}
var repeatX = distance / entity.polyline.width.getValue();
// 根据地图缩放程度调整repeatX
var cameraHeight = that.sdk.viewer.camera.positionCartographic.height;
var boundingSphere = new Cesium.BoundingSphere(
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
500000 // 半径(距离)
);
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
var drawingBufferWidth = that.sdk.viewer.canvas.clientWidth;
var drawingBufferHeight = that.sdk.viewer.canvas.clientHeight;
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1);
// if (entity.polyline.material.oriRepeat) {
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
let speed = repeatX / entity.polyline.oriRepeat
entity.polyline.oriSpeed = speed
entity.polyline.oriRepeatX = repeatX
} else {
let sdk3d = get3DView()
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
entity.polyline.oriSpeed = sdk3dEntity.polyline.oriSpeed
entity.polyline.oriRepeatX = sdk3dEntity.polyline.oriRepeatX
}
}
}
}
/**获取当前满屏横线速度 */
getSceenLine(entity, options, canvasEle) {
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
// var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
// var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
let ray = this.sdk.viewer.camera.getPickRay(point1);
let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
let ray2 = this.sdk.viewer.camera.getPickRay(point2);
let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
// if (!cartesian1 || !cartesian2) {
// let ray = this.sdk.viewer.camera.getPickRay(point1);
// cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
// let ray2 = this.sdk.viewer.camera.getPickRay(point2);
// cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
// }
if (cartesian1 && cartesian2) {
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
var repeatX = distance / entity.polyline.width.getValue();
// 根据地图缩放程度调整repeatX
var cameraHeight = this.sdk.viewer.camera.positionCartographic.height;
var boundingSphere = new Cesium.BoundingSphere(
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
500000 // 半径(距离)
);
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth;
var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight;
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
var groundResolution = this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
// repeatX *= groundResolution / cameraHeight / ((myImg.width / myImg.height * 5) + 1);
if (groundResolution > 700) {
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
} else {
repeatX = undefined;
}
if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
return repeatX
} else {
let sdk3d = get3DView()
let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id)
return sdk3dEntity.polyline.oriRepeatX
}
}
}
/**
* 编辑框
* @param {boolean} state true打开false关闭
*/
async edit(state) {
let _this = this
this.originalOptions = this.deepCopyObj(this.options)
if (this._DialogObject && this._DialogObject.close) {
this._DialogObject.close()
this._DialogObject = null
}
if (state) {
this._DialogObject = await new Dialog(this.sdk, this.options, {
title: '曲线属性',
left: '180px',
top: '100px',
confirmCallBack: options => {
this.name = this.name.trim()
if (!this.name) {
this.name = '未命名对象'
}
this.options.label.position = {
lng: this.label.position[0],
lat: this.label.position[1],
alt: this.label.position[2]
}
this.originalOptions = this.deepCopyObj(this.options)
this._DialogObject.close()
this.Dialog.confirmCallBack &&
this.Dialog.confirmCallBack(this.originalOptions)
syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
},
resetCallBack: () => {
this.reset()
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
},
removeCallBack: () => {
this.Dialog.removeCallBack && this.Dialog.removeCallBack()
},
closeCallBack: () => {
this.reset()
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
for (let i = 0; i < this.nodePoints.length; i++) {
this.sdk.viewer.entities.remove(this.nodePoints[i])
}
this.nodePoints = []
this.positionEditing = false
},
showCallBack: show => {
this.options.show = show
this.originalOptions.show = show
this.show = show
this.Dialog.showCallBack && this.Dialog.showCallBack()
},
translationalCallBack: () => {
this.positionEditing = !this.positionEditing
},
// 二次编辑回调
secondaryEditCallBack: () => {
this.positionEditing = false
this.noseToTail = false
this.heightMode = 0
CurvelineObject.nodeEdit(this)
}
})
this._DialogObject._element.body.className =
this._DialogObject._element.body.className + ' polyline'
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.attributeGoods = this.options.attribute.goods.content
function tabClick(e) {
if (e === '2' || e === 2) {//点击线条样式
if (2 < _this.options.type && _this.options.type < 13) {//贴图参数
document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex')
} else {
document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none')
}
}
}
// 创建标签页
let tabsElm = new cy_tabs(
'polyline-object-edit-tabs',
undefined,
this.sdk
)
// 颜色组件
let colorPicker = new YJColorPicker({
el: contentElm.getElementsByClassName('color')[0],
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.color,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.color = color
}, //点击确认按钮事件回调
clear: () => {
this.color = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
let labelColorPicker = new YJColorPicker({
el: contentElm.getElementsByClassName('labelColor')[0],
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.labelColor,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.labelColor = color
}, //点击确认按钮事件回调
clear: () => {
this.labelColor = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
let extendColorPicker = new YJColorPicker({
el: contentElm.getElementsByClassName('extendColor')[0],
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.extendColor,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.extendColor = color
}, //点击确认按钮事件回调
clear: () => {
this.extendColor = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
let lineColorPicker = new YJColorPicker({
el: contentElm.getElementsByClassName('labelLineColor')[0],
size: 'mini', //颜色box类型
alpha: true, //是否开启透明度
defaultColor: this.labelLineColor,
disabled: false, //是否禁止打开颜色选择器
openPickerAni: 'opacity', //打开颜色选择器动画
sure: color => {
this.labelLineColor = color
}, //点击确认按钮事件回调
clear: () => {
this.labelLineColor = 'rgba(255,255,255,1)'
} //点击清空按钮事件回调
})
let labelBackgroundColorStartPicker = new YJColorPicker({
el: contentElm.getElementsByClassName('labelBackgroundColorStart')[0],
size: 'mini',
alpha: true,
defaultColor: this.labelBackgroundColorStart,
disabled: false,
openPickerAni: 'opacity',
sure: color => {
this.labelBackgroundColorStart = color
},
clear: () => {
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
}
})
let labelBackgroundColorEndPicker = new YJColorPicker({
el: contentElm.getElementsByClassName('labelBackgroundColorEnd')[0],
size: 'mini',
alpha: true,
defaultColor: this.labelBackgroundColorEnd,
disabled: false,
openPickerAni: 'opacity',
sure: color => {
this.labelBackgroundColorEnd = color
},
clear: () => {
this.labelBackgroundColorEnd = 'rgba(255,255,255,1)'
}
})
let all_elm = contentElm.getElementsByTagName('*')
EventBinding.on(this, all_elm)
this._elms = EventBinding.element
this._elms.color = [colorPicker]
this._elms.labelColor = [labelColorPicker]
this._elms.extendColor = [extendColorPicker]
this._elms.labelLineColor = [lineColorPicker]
this._elms.labelBackgroundColorStart = [labelBackgroundColorStartPicker]
this._elms.labelBackgroundColorEnd = [labelBackgroundColorEndPicker]
setTimeout(() => {
this.attributeLink = this.options.attribute.link.content
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'
)[0]
if (attributeElm) {
let legpObject = legp(attributeElm, '.attribute-select')
legpObject.legp_search(tagData)
let attributeSelectElm = this._DialogObject._element.content
.getElementsByClassName('attribute-select')[0]
.getElementsByTagName('input')[0]
for (let i = 0; i < tagData.length; i++) {
if (tagData[i].key === this.options.attributeType) {
attributeSelectElm.value = tagData[i].value
legpObject.legp_searchActive(tagData[i].value)
break
}
}
attributeSelectElm.addEventListener('input', () => {
for (let i = 0; i < tagData.length; i++) {
if (tagData[i].value === attributeSelectElm.value) {
this.attributeType = tagData[i].key
break
}
}
})
}
let nameData = [
{
name: '空间长度',
value: '空间长度'
},
{
name: '投影长度',
value: '投影长度'
},
{
name: '地表长度',
value: '地表长度'
}
]
let nameDataLegpObject = legp(
this._DialogObject._element.content.getElementsByClassName(
'input-select-unit-box'
)[0],
'.input-select-unit'
)
if (nameDataLegpObject) {
nameDataLegpObject.legp_search(nameData)
let nameDataLegpElm = this._DialogObject._element.content
.getElementsByClassName('input-select-unit')[0]
.getElementsByTagName('input')[0]
this._elms.wordsName = [nameDataLegpElm]
nameDataLegpElm.value = this.options['words-name']
for (let i = 0; i < nameData.length; i++) {
if (nameData[i].value === nameDataLegpElm.value) {
nameDataLegpObject.legp_searchActive(nameData[i].value)
break
}
}
nameDataLegpElm.addEventListener('input', () => {
for (let i = 0; i < nameData.length; i++) {
if (nameData[i].value === nameDataLegpElm.value) {
this.wordsName = nameData[i].value
break
}
}
})
}
// 原始长度单位
let unitData = [
{
name: '米',
value: '米'
},
{
name: '千米',
value: '千米'
}
]
let unitDataLegpObject = legp(
this._DialogObject._element.content.getElementsByClassName(
'input-select-unit-box'
)[0],
'.input-select-unit',
1
)
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']
for (let i = 0; i < unitData.length; i++) {
if (unitData[i].value === unitDataLegpElm.value) {
unitDataLegpObject.legp_searchActive(unitData[i].value)
break
}
}
unitDataLegpElm.addEventListener('input', () => {
for (let i = 0; i < unitData.length; i++) {
if (unitData[i].value === unitDataLegpElm.value) {
this.lengthUnit = unitData[i].value
break
}
}
})
}
// 拟合长度单位
// let fitUnitData = [
// {
// name: '米',
// value: '米'
// },
// {
// name: '千米',
// value: '千米'
// }
// ]
// let fitUnitDataLegpObject = legp(
// this._DialogObject._element.content.getElementsByClassName(
// 'input-select-fit-unit-box'
// )[0],
// '.input-select-fit-unit'
// )
// if (fitUnitDataLegpObject) {
// fitUnitDataLegpObject.legp_search(fitUnitData)
// let fitUnitDataLegpElm = this._DialogObject._element.content
// .getElementsByClassName('input-select-fit-unit')[0]
// .getElementsByTagName('input')[0]
// this._elms.fitLengthUnit = [fitUnitDataLegpElm]
// fitUnitDataLegpElm.value = this.options['fit-length-unit']
// for (let i = 0; i < fitUnitData.length; i++) {
// if (fitUnitData[i].value === fitUnitDataLegpElm.value) {
// fitUnitDataLegpObject.legp_searchActive(fitUnitData[i].value)
// break
// }
// }
// fitUnitDataLegpElm.addEventListener('input', () => {
// for (let i = 0; i < fitUnitData.length; i++) {
// if (fitUnitData[i].value === fitUnitDataLegpElm.value) {
// this.fitLengthUnit = fitUnitData[i].value
// break
// }
// }
// })
// }
let lineTypeData = [
{
name: '<i class="icon line"></i>实线',
value: '实线',
key: 0,
icon: 'line'
},
{
name: '<i class="icon dash-line"></i>虚线',
value: '虚线',
key: 1,
icon: 'dash-line'
},
{
name: '<i class="icon light-line"></i>泛光',
value: '泛光',
key: 2,
icon: 'light-line'
},
{
name: '<i class="icon tail-line"></i>尾迹光线',
value: '尾迹光线',
key: 3,
icon: 'tail-line'
},
{
name: '<i class="icon mult-tail-line"></i>多尾迹光线',
value: '多尾迹光线',
key: 4,
icon: 'mult-tail-line'
},
{
name: '<i class="icon flow-dash-line1"></i>流动虚线1',
value: '流动虚线1',
key: 5,
icon: 'flow-dash-line1'
},
{
name: '<i class="icon flow-dash-line2"></i>流动虚线2',
value: '流动虚线2',
key: 6,
icon: 'flow-dash-line2'
},
{
name: '<i class="icon pic-line1"></i>流动箭头1',
value: '流动箭头1',
key: 7,
icon: 'pic-line1'
},
{
name: '<i class="icon pic-line2"></i>流动箭头2',
value: '流动箭头2',
key: 8,
icon: 'pic-line2'
},
{
name: '<i class="icon pic-line3"></i>流动箭头3',
value: '流动箭头3',
key: 9,
icon: 'pic-line3'
},
{
name: '<i class="icon pic-line4"></i>流动箭头4',
value: '流动箭头4',
key: 10,
icon: 'pic-line4'
},
{
name: '<i class="icon pic-line5"></i>流动箭头5',
value: '流动箭头5',
key: 11,
icon: 'pic-line5'
},
{
name: '<i class="icon pic-line6"></i>流动箭头6',
value: '流动箭头6',
key: 12,
icon: 'pic-line6'
}
]
let lineTypeDataLegpObject = legp(
this._DialogObject._element.content.getElementsByClassName(
'input-select-line-type-box'
)[0],
'.input-select-line-type'
)
if (lineTypeDataLegpObject) {
lineTypeDataLegpObject.legp_search(lineTypeData)
let iActiveElm2 = document.createElement('i')
iActiveElm2.className = 'icon icon-active'
this._DialogObject._element.content.getElementsByClassName('input-select-line-type')[0].getElementsByClassName('cy_datalist')[0].appendChild(iActiveElm2)
let lineTypeDataLegpElm = this._DialogObject._element.content
.getElementsByClassName('input-select-line-type')[0]
.getElementsByTagName('input')[0]
this._elms.lineType = [lineTypeDataLegpElm]
for (let i = 0; i < lineTypeData.length; i++) {
if (lineTypeData[i].key === this.options.type) {
lineTypeDataLegpObject.legp_searchActive(lineTypeData[i].value)
lineTypeDataLegpElm.value = lineTypeData[i].value
iActiveElm2.className = `icon icon-active ${lineTypeData[i].icon}`
break
}
}
lineTypeDataLegpElm.addEventListener('input', () => {
for (let i = 0; i < lineTypeData.length; i++) {
if (lineTypeData[i].value === lineTypeDataLegpElm.value) {
this.lineType = lineTypeData[i].key
iActiveElm2.className = `icon icon-active ${lineTypeData[i].icon}`
//控制参数显隐
if (2 < this.lineType && this.lineType < 13) {//贴图参数
document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'flex')
} else {
document.getElementById('dashTextureDom') && (document.getElementById('dashTextureDom').style.display = 'none')
}
if (2 < this.lineType && this.lineType < 5) {//尾迹参数
document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'none')
document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'none')
} else {
document.getElementsByClassName('lineSpace')[0] && (document.getElementsByClassName('lineSpace')[0].style.display = 'flex')
document.getElementsByClassName('lineSpace')[1] && (document.getElementsByClassName('lineSpace')[1].style.display = 'flex')
}
break
}
}
})
}
let heightBoxElm = this._DialogObject._element.content.getElementsByClassName('height-box')[0]
let heightElm = heightBoxElm.getElementsByClassName('height')[0]
let heightConfirmElm = this._DialogObject._element.content.getElementsByClassName('height-confirm')[0]
heightElm.value = 10
if (this.heightMode == 2) {
heightBoxElm && (heightBoxElm.className = 'input-number input-number-unit-1 height-box disabled');
heightConfirmElm && heightConfirmElm.setAttribute('disabled', 'disabled');
}
else {
heightBoxElm && (heightBoxElm.className = 'input-number input-number-unit-1 height-box');
heightConfirmElm && heightConfirmElm.removeAttribute('disabled');
}
let heightModeData = [
{
name: '海拔高度',
value: '海拔高度',
key: '0',
},
{
name: '相对地表',
value: '相对地表',
key: '1',
},
{
name: '依附模型',
value: '依附模型',
key: '2',
}
]
let heightModeObject = legp(
this._DialogObject._element.content.getElementsByClassName(
'height-mode-box'
)[0],
'.height-mode'
)
if (heightModeObject) {
heightModeObject.legp_search(heightModeData)
let heightModeDataLegpElm = this._DialogObject._element.content
.getElementsByClassName('height-mode')[0]
.getElementsByTagName('input')[0]
for (let i = 0; i < heightModeData.length; i++) {
if (heightModeData[i].key == this.heightMode) {
heightModeDataLegpElm.value = heightModeData[i].value
heightModeObject.legp_searchActive(
heightModeData[i].value
)
break
}
}
heightModeDataLegpElm.addEventListener('input', () => {
for (let i = 0; i < heightModeData.length; i++) {
if (heightModeData[i].value === heightModeDataLegpElm.value) {
this.heightMode = heightModeData[i].key
break
}
}
})
heightElm.addEventListener('input', () => {
switch (this.heightMode) {
case 0:
case '0':
break;
case 1:
case '1':
break;
case 2:
case '2':
break;
}
})
this._elms.height = heightElm
this._elms.heightBox = heightBoxElm
this._elms.heightMode = heightModeDataLegpElm
this._elms.heightConfirm = heightConfirmElm
this._elms.heightModeObject = heightModeObject
heightConfirmElm.addEventListener('click', () => {
this.positionEditing = false
for (let i = 0; i < this.options.positions.length; i++) {
this.options.positions[i].alt = Number((this.options.positions[i].alt + Number(heightElm.value)).toFixed(2))
this._elms.alt[i].innerHTML = this.options.positions[i].alt
}
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
fromDegreesArray
)
this.positionEditing = false
CurvelineObject.closeNodeEdit(this)
})
}
let tableElm = contentElm.getElementsByClassName('spatial-info-table')[0]
let tBodyElm = tableElm.getElementsByClassName('table-body')[0]
this._elms.lng = []
this._elms.lngInput = []
this._elms.lat = []
this._elms.latInput = []
this._elms.alt = []
this._elms.altInput = []
for (let i = 0; i < this.options.positions.length; i++) {
let tr = document.createElement('div')
tr.className = 'tr'
tr.innerHTML = `
<div class="td">${i + 1}</div>
<div class="td lng align-center"></div>
<div class="td lat align-center"></div>
<div class="td alt align-center"></div>
`
let lngBox = tr.getElementsByClassName('lng')[0]
let lng = document.createElement('span')
lng.innerHTML = (this.options.positions[i].lng).toFixed(8)
lngBox.appendChild(lng)
let lngInput = document.createElement('input')
lngInput.className = 'input'
lngInput.type = 'number'
lngInput.title = ''
lngInput.min = -180
lngInput.max = 180
lngInput.value = (this.options.positions[i].lng).toFixed(8)
let latBox = tr.getElementsByClassName('lat')[0]
let lat = document.createElement('span')
lat.innerHTML = (this.options.positions[i].lat).toFixed(8)
latBox.appendChild(lat)
let latInput = document.createElement('input')
latInput.className = 'input'
latInput.type = 'number'
latInput.title = ''
latInput.min = -90
latInput.max = 90
latInput.value = (this.options.positions[i].lat).toFixed(8)
let altBox = tr.getElementsByClassName('alt')[0]
let alt = document.createElement('span')
alt.innerHTML = (this.options.positions[i].alt).toFixed(2)
altBox.appendChild(alt)
let altInput = document.createElement('input')
altInput.className = 'input'
altInput.type = 'number'
altInput.title = ''
altInput.min = -9999999
altInput.max = 999999999
altInput.value = (this.options.positions[i].alt).toFixed(2)
lngBox.addEventListener('dblclick', () => {
lngBox.innerHTML = ''
lngInput.value = Number(this.options.positions[i].lng.toFixed(8))
lngBox.appendChild(lngInput)
lngInput.focus()
this.positionEditing = false
CurvelineObject.closeNodeEdit(this)
})
lngInput.addEventListener('blur', () => {
lngInput.value = Number(this.options.positions[i].lng.toFixed(8))
lngBox.innerHTML = ''
lngBox.appendChild(lng)
})
lngInput.addEventListener('input', () => {
this.options.positions[i].lng = Number(Number(lngInput.value).toFixed(8))
lng.innerHTML = this.options.positions[i].lng.toFixed(8)
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
this.label.position = [this.options.positions[0].lng, this.options.positions[0].lat, fromDegreesArray[2]]
})
latBox.addEventListener('dblclick', () => {
latBox.innerHTML = ''
latInput.value = Number(this.options.positions[i].lat.toFixed(8))
latBox.appendChild(latInput)
latInput.focus()
this.positionEditing = false
CurvelineObject.closeNodeEdit(this)
})
latInput.addEventListener('blur', () => {
latInput.value = Number(this.options.positions[i].lat.toFixed(8))
latBox.innerHTML = ''
latBox.appendChild(lat)
})
latInput.addEventListener('input', () => {
this.options.positions[i].lat = Number(Number(latInput.value).toFixed(8))
lat.innerHTML = this.options.positions[i].lat.toFixed(8)
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
this.label.position = [this.options.positions[0].lng, this.options.positions[0].lat, fromDegreesArray[2]]
})
altBox.addEventListener('dblclick', () => {
if (this.heightMode == 2) {
return;
}
altBox.innerHTML = ''
altInput.value = Number(this.options.positions[i].alt.toFixed(2))
altBox.appendChild(altInput)
altInput.focus()
this.positionEditing = false
CurvelineObject.closeNodeEdit(this)
})
altInput.addEventListener('blur', () => {
altInput.value = Number(this.options.positions[i].alt.toFixed(2))
altBox.innerHTML = ''
altBox.appendChild(alt)
})
altInput.addEventListener('input', () => {
this.options.positions[i].alt = Number(Number(altInput.value).toFixed(2))
alt.innerHTML = this.options.positions[i].alt.toFixed(2)
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
this.label.position = [this.options.positions[0].lng, this.options.positions[0].lat, fromDegreesArray[2]]
})
this._elms.lng.push(lng)
this._elms.lngInput.push(lngInput)
this._elms.lat.push(lat)
this._elms.latInput.push(latInput)
this._elms.alt.push(alt)
this._elms.altInput.push(altInput)
tBodyElm.appendChild(tr)
}
let fontData = getFontList()
let fontObject = legp(
this._DialogObject._element.content.getElementsByClassName(
'font-select-box'
)[0],
'.font-select'
)
if (fontObject) {
fontObject.legp_search(fontData)
let fontDataLegpElm = this._DialogObject._element.content
.getElementsByClassName('font-select')[0]
.getElementsByTagName('input')[0]
fontDataLegpElm.value = fontData[this.labelFontFamily].value
for (let i = 0; i < fontData.length; i++) {
if (fontData[i].value == fontDataLegpElm.value) {
fontObject.legp_searchActive(fontData[i].value)
break
}
}
fontDataLegpElm.addEventListener('input', () => {
for (let i = 0; i < fontData.length; i++) {
if (fontData[i].value === fontDataLegpElm.value) {
this.labelFontFamily = fontData[i].key
break
}
}
})
this._elms.labelFontFamily = [fontDataLegpElm]
}
}, 0)
} else {
if (this._DialogObject && this._DialogObject.close) {
this._DialogObject.close()
this._DialogObject = null
}
}
}
// 平滑处理
smoothHandle(positions) {
let newPositions = []
let time = []
let fromDegreesArrayHeights = []
for (let i = 0; i < positions.length; i++) {
fromDegreesArrayHeights.push(
positions[i].lng,
positions[i].lat,
positions[i].alt
)
time.push(i / (positions.length - 1))
}
let spline = new Cesium.CatmullRomSpline({
times: time,
points: Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArrayHeights)
})
let length = positions.length * 20
for (let i = 0; i <= length; i++) {
let cartesian3 = spline.evaluate(i / length)
newPositions.push(this.cartesian3Towgs84(cartesian3, this.sdk.viewer))
}
return newPositions
}
// 更新坐标
renewPositions(positionsArray) {
if (this._error) {
return
}
let positions = JSON.parse(JSON.stringify(positionsArray))
let ground
switch (this.heightMode) {
case 0:
case '0':
ground = false
break
case 1:
case '1':
for (let i = 0; i < positions.length; i++) {
let height = this.sdk.viewer.scene.globe.getHeight(Cesium.Cartographic.fromDegrees(positions[i].lng, positions[i].lat))
positions[i].alt = height ? Number((positions[i].alt + Number(height)).toFixed(2)) : Number((positions[i].alt).toFixed(2))
}
ground = false
break
case 2:
case '2':
ground = true
break
}
let newPositions
let fromDegreesArray = []
if (
this.options['nose-to-tail'] &&
this.options['nose-to-tail'] !== 'false'
) {
newPositions = [...positions, positions[0]]
} else {
newPositions = [...positions]
}
newPositions = this.smoothHandle(newPositions)
for (let i = 0; i < newPositions.length; i++) {
fromDegreesArray.push(
newPositions[i].lng,
newPositions[i].lat,
newPositions[i].alt
)
}
// 计算长度
// let array = []
// for (let i = 0; i < fromDegreesArray.length; i += 3) {
// array.push({
// lng: fromDegreesArray[i],
// lat: fromDegreesArray[i + 1],
// alt: fromDegreesArray[i + 2]
// })
// }
// this.options.fitLengthByMeter = this.computeDistance2(
// array,
// 2,
// ground
// )
// this.fitLengthUnit = this.options['fit-length-unit']
// this.options.lengthByMeter = this.computeDistance2(this.smoothHandle(positions), 2, ground)
// this.lengthUnit = this.options['length-unit']
if (
(this.options['nose-to-tail'] &&
this.options['nose-to-tail'] !== 'false') ||
(this.options.smooth && this.options.smooth !== 'false')
) {
let array = []
for (let i = 0; i < fromDegreesArray.length; i += 3) {
array.push({
lng: fromDegreesArray[i],
lat: fromDegreesArray[i + 1],
alt: fromDegreesArray[i + 2]
})
}
// this.options.fitLengthByMeter = this.computeDistance(
// array,
// 2,
// ground
// )
let _this = this
this.computeDistance(
array,
2,
this.options['words-name']
).then(res => {
_this.options.fitLengthByMeter = res
_this.lengthUnit = _this.options['length-unit']
})
} else {
let _this = this
this.computeDistance(
_this.smoothHandle(positions),
2,
this.options['words-name']
).then(res => {
_this.options.fitLengthByMeter = res
_this.lengthUnit = _this.options['length-unit']
})
}
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
}
// 更新多边形(线扩展)
renewPolygon(fromDegreesArray) {
let linePositions = []
if (this.options.extend && this.options.extend !== 'false') {
let outerHole = []
for (let i = 0; i < fromDegreesArray.length; i += 3) {
linePositions.push([fromDegreesArray[i], fromDegreesArray[i + 1]])
}
let linestring = turf.lineString(linePositions)
let buffered = turf.buffer(
linestring,
this.options['extend-width'] / 1000,
{ units: 'kilometers' }
)
for (let i = 0; i < buffered.geometry.coordinates[0].length; i++) {
outerHole.push(
buffered.geometry.coordinates[0][i][0],
buffered.geometry.coordinates[0][i][1]
)
}
let holes = [] // 孔
for (let i = 1; i < buffered.geometry.coordinates.length; i++) {
let array = []
for (let m = 0; m < buffered.geometry.coordinates[i].length; m++) {
array.push(
buffered.geometry.coordinates[i][m][0],
buffered.geometry.coordinates[i][m][1]
)
}
holes.push({ positions: Cesium.Cartesian3.fromDegreesArray(array) })
}
this.entity.polygon = new Cesium.PolygonGraphics({
hierarchy: {
positions: Cesium.Cartesian3.fromDegreesArray(outerHole),
holes: holes
},
material: Cesium.Color.fromCssColorString(this.options['extend-color'])
})
} else {
this.entity.polygon = undefined
}
}
async reset() {
if (!this.entity) {
return
}
this.options = this.deepCopyObj(this.originalOptions)
this.name = this.originalOptions.name
this.color = this.originalOptions.color
this.lineWidth = this.originalOptions.width
this.lineType = this.originalOptions.type
this.noseToTail = this.originalOptions['nose-to-tail']
this.extend = this.originalOptions.extend
this.extendWidth = this.originalOptions['extend-width']
this.extendColor = this.originalOptions['extend-color']
this.labelShow = this.originalOptions.label.show
this.labelColor = this.originalOptions.label.color
this.labelFontSize = this.originalOptions.label.fontSize
this.labelFontFamily = this.originalOptions.label.fontFamily
this.labelScaleByDistance = this.originalOptions.label.scaleByDistance
this.labelNear = this.originalOptions.label.near
this.labelFar = this.originalOptions.label.far
this.labelLineWidth = this.originalOptions.label.lineWidth
this.labelPixelOffset = this.originalOptions.label.pixelOffset
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.rotate = this.originalOptions.rotate
this.speed = this.originalOptions.speed
this.dashSize = this.originalOptions.dashSize
this.space = this.originalOptions.space
this.cameraSelect && this.cameraSelect()
this.goodsSelect && this.goodsSelect()
this.heightMode = this.options.heightMode
// let height
// if (this.ground) {
// height = await that.getClampToHeight({
// lng: this.options.positions[0].lng,
// lat: this.options.positions[0].lat
// })
// } else {
// height = this.options.positions[0].alt
// }
// this.options.label.position = {
// lng: this.options.positions[0].lng,
// lat: this.options.positions[0].lat,
// alt: height
// }
// this.label.position = [
// this.options.label.position.lng,
// this.options.label.position.lat,
// this.options.label.position.alt
// ]
}
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() {
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
}
/**
* 飞到
*/
async flyTo(options = {}) {
if (this._error) {
return
}
closeRotateAround(this.sdk)
closeViewFollow(this.sdk)
setActiveViewer(0)
if (this.options.customView) {
let orientation = {
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
}
let lng = this.options.customView.relativePosition.lng
let lat = this.options.customView.relativePosition.lat
let alt = this.options.customView.relativePosition.alt
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
let position = { lng: 0, lat: 0 }
if (this.options.position) {
position = { ...this.options.position }
}
else if (this.options.positions) {
position = { ...this.options.positions[0] }
}
else if (this.options.center) {
position = { ...this.options.center }
}
else if (this.options.start) {
position = { ...this.options.start }
}
else {
if (this.options.hasOwnProperty('lng')) {
position.lng = this.options.lng
}
if (this.options.hasOwnProperty('lat')) {
position.lat = this.options.lat
}
if (this.options.hasOwnProperty('alt')) {
position.alt = this.options.alt
}
}
// 如果没有高度值,则获取紧贴高度计算
if (!position.hasOwnProperty('alt')) {
position.alt = await this.getClampToHeight(position)
}
lng = this.options.customView.relativePosition.lng + position.lng
lat = this.options.customView.relativePosition.lat + position.lat
alt = this.options.customView.relativePosition.alt + position.alt
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
this.sdk.viewer.camera.flyTo({
destination: destination,
orientation: orientation
})
}
else {
let positionArray = []
let height
switch (this.options.heightMode) {
case '0':
case 0:
for (let i = 0; i < this.options.positions.length; i++) {
let a = Cesium.Cartesian3.fromDegrees(
this.options.positions[i].lng,
this.options.positions[i].lat,
this.options.positions[i].alt
)
positionArray.push(a.x, a.y, a.z)
}
break
case '1':
case 1:
height = await this.getClampToHeight(this.options.positions[0])
for (let i = 0; i < this.options.positions.length; i++) {
let a = Cesium.Cartesian3.fromDegrees(
this.options.positions[i].lng,
this.options.positions[i].lat,
height + this.options.positions[i].alt
)
positionArray.push(a.x, a.y, a.z)
}
break
case '2':
case 2:
height = await this.getClampToHeight(this.options.positions[0])
for (let i = 0; i < this.options.positions.length; i++) {
let a = Cesium.Cartesian3.fromDegrees(
this.options.positions[i].lng,
this.options.positions[i].lat,
height
)
positionArray.push(a.x, a.y, a.z)
}
break
}
let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray)
this.sdk.viewer.camera.flyToBoundingSphere(BoundingSphere, {
offset: options.orientation || {
heading: Cesium.Math.toRadians(0.0),
pitch: Cesium.Math.toRadians(-90.0),
roll: Cesium.Math.toRadians(0.0)
}
})
}
}
/**
* 打开富文本框
*/
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()) {
// cb('上一次测量未结束')
// } else {
// YJ.Measure.SetMeasureStatus(true)
// that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
// that.event = new MouseEvent(that.sdk)
// that.nodePoints = []
// let selectPoint
// let originalPosition
// let newpositions = []
// let fromDegreesArray = []
// for (let i = 0; i < that.options.positions.length; i++) {
// fromDegreesArray.push(
// that.options.positions[i].lng,
// that.options.positions[i].lat,
// that.options.positions[i].alt
// )
// }
// newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
// that.event.mouse_left((movement, cartesian) => {
// if (selectPoint) {
// that.options.positions[selectPoint.index] = that.cartesian3Towgs84(
// cartesian,
// that.sdk.viewer
// )
// originalPosition = that.options.positions[selectPoint.index]
// let entity = that.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
// ),
// billboard: {
// image: that.getSourceRootPath() + '/img/point.png',
// width: 15,
// height: 15,
// disableDepthTestDistance: Number.POSITIVE_INFINITY
// }
// })
// that.nodePoints.splice(selectPoint.index, 0, entity)
// that.options.positions.splice(
// selectPoint.index,
// 0,
// that.options.positions[selectPoint.index]
// )
// let fromDegreesArray = that.renewPositions(that.options.positions)
// that.renewPolygon(fromDegreesArray)
// that.options.lengthByMeter = that.computeDistance2(
// that.options.positions,
// 2,
// that.ground
// )
// that.lengthUnit = that.options['length-unit']
// } else {
// var pick = that.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.event.mouse_right((movement, cartesian) => {
// if (selectPoint) {
// that.options.positions[selectPoint.index] = originalPosition
// cb(null, that.options.positions)
// }
// let positions = that.options.positions
// let fromDegreesArray = []
// for (let i = 0; i < positions.length; i++) {
// fromDegreesArray.push(
// positions[i].lng,
// positions[i].lat,
// positions[i].alt
// )
// }
// newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(
// fromDegreesArray
// )
// for (let i = 0; i < that.nodePoints.length; i++) {
// that.sdk.viewer.entities.remove(that.nodePoints[i])
// }
// that.nodePoints = []
// that.event.destroy()
// that.tip.destroy()
// })
// that.event.mouse_move((movement, cartesian) => {
// if (selectPoint) {
// that.options.positions[selectPoint.index] = that.cartesian3Towgs84(
// cartesian,
// that.sdk.viewer
// )
// let positions = that.options.positions
// let fromDegreesArray = []
// for (let i = 0; i < positions.length; i++) {
// fromDegreesArray.push(
// positions[i].lng,
// positions[i].lat,
// positions[i].alt
// )
// }
// newpositions = Cesium.Cartesian3.fromDegreesArrayHeights(
// fromDegreesArray
// )
// if (that.options.positions.length === 1) {
// that.label.position = [
// that.options.positions[0].lng,
// that.options.positions[0].lat,
// that.options.positions[0].alt
// ]
// that.options.label.position = {
// lng: that.options.positions[0].lng,
// lat: that.options.positions[0].lat,
// alt: that.options.positions[0].alt
// }
// }
// }
// that.tip.setPosition(
// cartesian,
// movement.endPosition.x,
// movement.endPosition.y
// )
// })
// that.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]
// } else {
// selectPoint.index = 0
// }
// }
// }
// })
// that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
// return newpositions
// }, false)
// for (let i = 0; i < that.options.positions.length; i++) {
// let entity = that.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
// ),
// billboard: {
// image: that.getSourceRootPath() + '/img/point.png',
// width: 15,
// height: 15,
// disableDepthTestDistance: Number.POSITIVE_INFINITY
// }
// })
// that.nodePoints.push(entity)
// }
// }
// }
static nodeEdit(that, start = true) {
that.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)
let selectPoint
that.event.mouse_left((movement, cartesian) => {
var pick = that.sdk.viewer.scene.pick(movement.position)
if (
pick &&
pick.id &&
pick.id.name &&
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 => {
if (selectPoint.index === 0) {
that.label.position = [
params.position.lng,
params.position.lat,
params.position.alt
]
that.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))
selectPoint.position = Cesium.Cartesian3.fromDegrees(
params.position.lng,
params.position.lat,
params.position.alt
)
}
}
})
that.event.mouse_right((movement, cartesian) => {
for (let i = 0; i < that.nodePoints.length; i++) {
that.sdk.viewer.entities.remove(that.nodePoints[i])
}
that.nodePoints = []
that.event.destroy()
that.tip && that.tip.destroy()
that.tip = null
that.ControllerObject.destroy()
let fromDegreesArray = that.renewPositions(that.options.positions)
that.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
})
that.event.mouse_move((movement, cartesian) => {
that.tip.setPosition(
cartesian,
movement.endPosition.x,
movement.endPosition.y
)
})
that.entity.polyline.positions = new Cesium.CallbackProperty(function () {
let fromDegreesArray = that.renewPositions(that.options.positions)
return Cesium.Cartesian3.fromDegreesArrayHeights(fromDegreesArray)
}, false)
for (let i = 0; i < that.options.positions.length; i++) {
let entity = that.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
),
billboard: {
image: that.getSourceRootPath() + '/img/point.png',
width: 15,
height: 15,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
color: Cesium.Color.WHITE.withAlpha(0.99)
}
})
that.nodePoints.push(entity)
}
}
}
static closeNodeEdit(that) {
that.ControllerObject && that.ControllerObject.destroy()
that.event && that.event.destroy()
that.tip && that.tip.destroy()
that.tip = null
for (let i = 0; i < that.nodePoints.length; i++) {
that.sdk.viewer.entities.remove(that.nodePoints[i])
}
that.nodePoints = []
}
/**
* 删除
*/
async remove() {
this.event && this.event.destroy()
this.tip && this.tip.destroy()
this.label && this.label.remove()
this.sdk.viewer.entities.remove(this.entity)
this.entity = null
if (this._DialogObject && !this._DialogObject.isDestroy) {
this._DialogObject.close()
this._DialogObject = null
}
await this.sdk.removeIncetance(this.options.id)
await syncData(this.sdk, this.options.id)
}
/**@desc 打开平移功能
*
* @memberOf Source
* @param status {boolean}
*
* */
set positionEditing(status) {
if (YJ.Measure.GetMeasureStatus() || !this.sdk || !this.sdk.viewer || !this.entity) {
return
}
this.operate.positionEditing = status
if (status === true) {
CurvelineObject.closeNodeEdit(this)
this.event && this.event.destroy()
this.event = new MouseEvent(this.sdk)
this.tip && this.tip.destroy()
this.tip = new MouseTip('点击鼠标左键确认,右键取消', this.sdk)
this.label &&
(this.label.entity.billboard.color = Cesium.Color.fromCssColorString(
`rgba(255,255,255,0.9)`
))
this.picking = false
let positions = JSON.parse(JSON.stringify(this.options.positions))
let positions2 = this.renewPositions(this.options.positions)
// let positions2 = JSON.parse(JSON.stringify(positions))
// for (let i = 0; i < positions2.length; i++) {
// let height = this.sdk.viewer.scene.globe.getHeight(Cesium.Cartographic.fromDegrees(positions2[i].lng, positions2[i].lat))
// positions2[i] = Cesium.Cartesian3.fromDegrees(
// positions2[i].lng,
// positions2[i].lat,
// Number((positions2[i].alt + Number(height)).toFixed(2))
// )
// }
this.previous = {
positions: [...this.options.positions]
}
for (let i = 0; i < positions.length; i++) {
positions[i] = Cesium.Cartesian3.fromDegrees(
positions[i].lng,
positions[i].lat,
positions[i].alt
)
}
let center = positions[Math.floor(positions.length / 2)]
let disparity = []
for (let i = 0; i < positions.length; i++) {
disparity.push({
x: center.x - positions[i].x,
y: center.y - positions[i].y,
z: center.z - positions[i].z
})
}
let newpositions = []
let newpositions84 = []
this.event.mouse_move((movement, cartesian) => {
newpositions = []
newpositions84 = []
for (let i = 0; i < disparity.length; i++) {
let newP = {
x: cartesian.x - disparity[i].x,
y: cartesian.y - disparity[i].y,
z: cartesian.z - disparity[i].z
}
let pos84 = this.cartesian3Towgs84(
newP,
this.sdk.viewer
)
pos84.alt = this.options.positions[i].alt
// let height = this.sdk.viewer.scene.globe.getHeight(Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat))
// pos84.alt = Number((pos84.alt + Number(height)).toFixed(2))
// newP = Cesium.Cartesian3.fromDegrees(
// pos84.lng,
// pos84.lat,
// pos84.alt
// )
newpositions.push(newP)
newpositions84.push(pos84)
}
let position84 = newpositions84[0]
positions2 = this.renewPositions(newpositions84)
this.label.position = [position84.lng, position84.lat, position84.alt]
this.options.label.position = {
lng: position84.lng,
lat: position84.lat,
alt: position84.alt
}
this.tip.setPosition(
cartesian,
movement.endPosition.x,
movement.endPosition.y
)
})
this.event.mouse_left((movement, cartesian) => {
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
newpositions = []
newpositions84 = []
for (let i = 0; i < disparity.length; i++) {
let newP = {
x: cartesian.x - disparity[i].x,
y: cartesian.y - disparity[i].y,
z: cartesian.z - disparity[i].z
}
let pos84 = this.cartesian3Towgs84(
newP,
this.sdk.viewer
)
pos84.alt = this.options.positions[i].alt
newpositions.push(newP)
newpositions84.push(pos84)
}
let positionsLngLat = []
for (let i = 0; i < newpositions84.length; i++) {
let position = newpositions84[i]
positionsLngLat.push(position)
this._elms.lng && (this._elms.lng[i].innerHTML = position.lng.toFixed(8))
this._elms.lngInput && (this._elms.lngInput[i].value = position.lng.toFixed(8))
this._elms.lat && (this._elms.lat[i].innerHTML = position.lat.toFixed(8))
this._elms.latInput && (this._elms.latInput[i].value = position.lat.toFixed(8))
this._elms.alt && (this._elms.alt[i].innerHTML = position.alt.toFixed(2))
this._elms.altInput && (this._elms.altInput[i].value = position.alt.toFixed(2))
}
this.options.positions = positionsLngLat
this.previous.positions = positionsLngLat
// this.entity.polyline.positionsLngLat = positionsLngLat
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
fromDegreesArray
)
this.renewPolygon(fromDegreesArray)
this.positionEditing = false
})
this.event.mouse_right((movement, cartesian) => {
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
this.positionEditing = false
})
this.event.gesture_pinck_start((movement, cartesian) => {
let startTime = new Date()
this.event.gesture_pinck_end(() => {
let endTime = new Date()
let pos = {
position: {
x: (movement.position1.x + movement.position2.x) / 2,
y: (movement.position1.y + movement.position2.y) / 2
}
}
if (endTime - startTime >= 500) {
// 长按取消
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
this.positionEditing = false
} else {
leftEvent(pos, cartesian)
}
})
})
this.entity.polyline.positions = new Cesium.CallbackProperty(function () {
return Cesium.Cartesian3.fromDegreesArrayHeights(
positions2
)
}, false)
} else {
if (!this.sdk || !this.sdk.viewer || !this.label || !this.label.entity) {
this.label.entity.billboard.color = Cesium.Color.fromCssColorString(
`rgba(255,255,255,1)`
)
}
this.picking = true
if (this.event) {
this.event.mouse_move(() => { })
this.event.mouse_left(() => { })
this.event.mouse_right(() => { })
this.event.destroy()
}
this.tip && this.tip.destroy()
let fromDegreesArray = this.renewPositions(this.options.positions)
this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
fromDegreesArray
)
this.renewPolygon(fromDegreesArray)
switch (this.heightMode) {
case 0:
case '0':
case 1:
case '1':
this.label.position = [
this.options.positions[0].lng,
this.options.positions[0].lat,
fromDegreesArray[2]
]
this.options.label.position = {
lng: this.options.positions[0].lng,
lat: this.options.positions[0].lat,
alt: fromDegreesArray[2]
}
break;
case 2:
case '2':
break;
}
}
}
get positionEditing() {
return this.operate.positionEditing
}
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 points = []
for (let i = 0; i < this.options.positions.length; i++) {
points.push([
this.options.positions[i].lng,
this.options.positions[i].lat
])
}
let line = turf.lineString(points)
let length = turf.length(line, { units: 'kilometers' })
let sliced = turf.lineSliceAlong(line, 0, length / 2, {
units: 'kilometers'
})
let siteInfoDom = document.getElementById(options.domid)
let siteInfoPosition = Cesium.Cartesian3.fromDegrees(
...sliced.geometry.coordinates[sliced.geometry.coordinates.length - 1]
)
this.sdk.viewer.scene.postRender.addEventListener(percentage => {
//转换到屏幕坐标
if (
siteInfoDom.style.display === 'block' ||
siteInfoDom.style.display === ''
) {
let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates(
siteInfoPosition
)
if (winpos) {
siteInfoDom.style.left = (winpos.x + options.x).toFixed(0) + 'px'
siteInfoDom.style.top = (winpos.y + options.y).toFixed(0) + 'px'
}
}
})
}
}
export default CurvelineObject