修改position
This commit is contained in:
@ -10,7 +10,7 @@ class TextBox extends Base {
|
|||||||
* @description 文本框
|
* @description 文本框
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
* @param options.id=id
|
* @param options.id=id
|
||||||
* @param options.positions=[]位置
|
* @param options.position=[]位置
|
||||||
* @param options.text=文本框内容
|
* @param options.text=文本框内容
|
||||||
* @param options.show=true {boolean}是否显示
|
* @param options.show=true {boolean}是否显示
|
||||||
* @param callback=方法回调
|
* @param callback=方法回调
|
||||||
@ -21,7 +21,7 @@ class TextBox extends Base {
|
|||||||
// this.sdk = { ...sdk }
|
// this.sdk = { ...sdk }
|
||||||
// this.options = { ...options }
|
// this.options = { ...options }
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
this.options.positions = options.positions || []
|
this.options.position = options.position || []
|
||||||
this.options.text = options.text || ''
|
this.options.text = options.text || ''
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.clickTextDom = undefined
|
this.clickTextDom = undefined
|
||||||
@ -53,7 +53,7 @@ class TextBox extends Base {
|
|||||||
|
|
||||||
// 配置CSS样式和内容结构
|
// 配置CSS样式和内容结构
|
||||||
viewer.cesiumWidget.container.appendChild(dom);
|
viewer.cesiumWidget.container.appendChild(dom);
|
||||||
let posi = Cesium.Cartesian3.fromDegrees(that.options.positions.lng, that.options.positions.lat, that.options.positions.alt)
|
let posi = Cesium.Cartesian3.fromDegrees(that.options.position.lng, that.options.position.lat, that.options.position.alt)
|
||||||
|
|
||||||
that.handler = function () {
|
that.handler = function () {
|
||||||
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||||
@ -80,7 +80,7 @@ class TextBox extends Base {
|
|||||||
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
||||||
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||||
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||||
that.positions = {
|
that.position = {
|
||||||
lng: longitude,
|
lng: longitude,
|
||||||
lat: latitude,
|
lat: latitude,
|
||||||
alt: cartographic.height
|
alt: cartographic.height
|
||||||
@ -115,11 +115,11 @@ class TextBox extends Base {
|
|||||||
this.options.show = v
|
this.options.show = v
|
||||||
this.textDom && (this.textDom.style.display = v ? 'block' : 'none');
|
this.textDom && (this.textDom.style.display = v ? 'block' : 'none');
|
||||||
}
|
}
|
||||||
get positions() {
|
get position() {
|
||||||
return this.options.positions
|
return this.options.position
|
||||||
}
|
}
|
||||||
set positions(v) {
|
set position(v) {
|
||||||
this.options.positions = v
|
this.options.position = v
|
||||||
}
|
}
|
||||||
async flyTo(options = {}) {
|
async flyTo(options = {}) {
|
||||||
setActiveViewer(0)
|
setActiveViewer(0)
|
||||||
@ -142,8 +142,8 @@ class TextBox extends Base {
|
|||||||
if (this.options.position) {
|
if (this.options.position) {
|
||||||
position = { ...this.options.position }
|
position = { ...this.options.position }
|
||||||
}
|
}
|
||||||
else if (this.options.positions) {
|
else if (this.options.position) {
|
||||||
position = { ...this.options.positions[0] }
|
position = { ...this.options.position[0] }
|
||||||
}
|
}
|
||||||
else if (this.options.center) {
|
else if (this.options.center) {
|
||||||
position = { ...this.options.center }
|
position = { ...this.options.center }
|
||||||
@ -178,9 +178,9 @@ class TextBox extends Base {
|
|||||||
else {
|
else {
|
||||||
let positionArray = []
|
let positionArray = []
|
||||||
let a = Cesium.Cartesian3.fromDegrees(
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
this.positions.lng,
|
this.position.lng,
|
||||||
this.positions.lat,
|
this.position.lat,
|
||||||
this.positions.alt
|
this.position.alt
|
||||||
)
|
)
|
||||||
positionArray.push(a.x, a.y, a.z)
|
positionArray.push(a.x, a.y, a.z)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user