合并
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞到
|
||||
*/
|
||||
|
Reference in New Issue
Block a user