文本框位置
This commit is contained in:
@ -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.position.lng.toFixed(4), that.options.position.lat.toFixed(4), that.options.position.alt.toFixed(4))
|
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(
|
||||||
viewer.scene, posi
|
viewer.scene, posi
|
||||||
@ -71,8 +71,16 @@ class TextBox extends Base {
|
|||||||
}
|
}
|
||||||
async setHandeler(data) {
|
async setHandeler(data) {
|
||||||
let that = this
|
let that = this
|
||||||
const ray = this.sdk.viewer.camera.getPickRay(new Cesium.Cartesian2(data.x, data.y));
|
|
||||||
var cartesian = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
let cartesian = this.sdk.viewer.scene.pickPosition(new Cesium.Cartesian2(data.x, data.y)); //屏幕坐标转为笛卡尔空间坐标
|
||||||
|
// if (!cartesian) return;
|
||||||
|
|
||||||
|
// let c = Cesium.Cartographic.fromCartesian(position);
|
||||||
|
if (!cartesian) {
|
||||||
|
const ray = this.sdk.viewer.camera.getPickRay(new Cesium.Cartesian2(data.x, data.y));
|
||||||
|
cartesian = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
}
|
||||||
|
|
||||||
if (Cesium.defined(cartesian)) {
|
if (Cesium.defined(cartesian)) {
|
||||||
that.sdk.viewer.scene.postRender.removeEventListener(that.handler);
|
that.sdk.viewer.scene.postRender.removeEventListener(that.handler);
|
||||||
|
|
||||||
@ -84,10 +92,10 @@ class TextBox extends Base {
|
|||||||
that.position = {
|
that.position = {
|
||||||
lng: longitude,
|
lng: longitude,
|
||||||
lat: latitude,
|
lat: latitude,
|
||||||
// alt: cartographic.height
|
alt: cartographic.height
|
||||||
alt: height
|
// alt: height
|
||||||
}
|
}
|
||||||
let posi = Cesium.Cartesian3.fromDegrees(longitude.toFixed(4), latitude.toFixed(4), height.toFixed(4))
|
let posi = Cesium.Cartesian3.fromDegrees(longitude, latitude, cartographic.height)
|
||||||
|
|
||||||
that.handler = function () {
|
that.handler = function () {
|
||||||
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||||
|
Reference in New Issue
Block a user