Compare commits
7 Commits
f1e0ac166e
...
71988d8833
Author | SHA1 | Date | |
---|---|---|---|
71988d8833 | |||
dd1c7acde1 | |||
644c0d2e28 | |||
e51357efa7 | |||
379a560fbc | |||
a4cd365c83 | |||
3358221da9 |
@ -121,6 +121,9 @@ function MouseRightMenu(sdk, status, callBack) {
|
|||||||
<ul class="base" style="list-style: none;padding: 0;margin: 0;font-size: 12px;">
|
<ul class="base" style="list-style: none;padding: 0;margin: 0;font-size: 12px;">
|
||||||
<li style="padding: 3px 10px;cursor: pointer;">绕鼠标点旋转</li>
|
<li style="padding: 3px 10px;cursor: pointer;">绕鼠标点旋转</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul class="base" style="list-style: none;padding: 0;margin: 0;font-size: 12px;">
|
||||||
|
<li style="padding: 3px 10px;cursor: pointer;">文本框</li>
|
||||||
|
</ul>
|
||||||
${addedMenu}
|
${addedMenu}
|
||||||
`
|
`
|
||||||
_element.appendChild(menuElm)
|
_element.appendChild(menuElm)
|
||||||
@ -175,6 +178,7 @@ function MouseRightMenu(sdk, status, callBack) {
|
|||||||
break
|
break
|
||||||
case '文本框':
|
case '文本框':
|
||||||
object.position = position
|
object.position = position
|
||||||
|
key = 'textBox'
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
eventListener[sdk.div_id].callBack(key, object)
|
eventListener[sdk.div_id].callBack(key, object)
|
||||||
|
@ -91,7 +91,7 @@ class MeasureDistance extends Measure {
|
|||||||
|
|
||||||
|
|
||||||
//暂时固定取20个点
|
//暂时固定取20个点
|
||||||
if (d > 20) {//大于20m时,固定取20个点
|
if (d > 2) {//大于20m时,固定取20个点
|
||||||
meters = d / 20
|
meters = d / 20
|
||||||
await start(meters)
|
await start(meters)
|
||||||
} else if (d < 1) {
|
} else if (d < 1) {
|
||||||
@ -106,8 +106,8 @@ class MeasureDistance extends Measure {
|
|||||||
|
|
||||||
|
|
||||||
async sampleHeight(p1, index) {
|
async sampleHeight(p1, index) {
|
||||||
let p2 = await this.sampleHeightMostDetailed([p1])
|
let height = await this.getClampToHeight(p1, [...this.sdk.viewer.entities.values])
|
||||||
p1.alt = p2[0].height
|
p1.alt = height
|
||||||
return {position: p1, index}
|
return {position: p1, index}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,15 +4,32 @@
|
|||||||
import Base from "../index";
|
import Base from "../index";
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
||||||
class TextBox extends Base {
|
class TextBox extends Base {
|
||||||
constructor(sdk, options = {}) {
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
|
* @description 文本框
|
||||||
|
* @param options {object} 属性
|
||||||
|
* @param options.id=id
|
||||||
|
* @param options.position=[]位置
|
||||||
|
* @param options.text=文本框内容
|
||||||
|
* @param options.show=true {boolean}是否显示
|
||||||
|
* @param callback=方法回调
|
||||||
|
* @param Dialog {object} 弹框对象
|
||||||
|
* @param Dialog.confirmCallBack {function} 弹框确认时的回调
|
||||||
|
* */
|
||||||
|
constructor(sdk, options = {}, callback = null) {
|
||||||
// this.sdk = { ...sdk }
|
// this.sdk = { ...sdk }
|
||||||
// this.options = { ...options }
|
// this.options = { ...options }
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
|
this.options.position = options.position || []
|
||||||
|
this.options.text = options.text || ''
|
||||||
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.clickTextDom = undefined
|
this.clickTextDom = undefined
|
||||||
this.handler = undefined
|
this.handler = undefined
|
||||||
this.textDom = undefined
|
this.textDom = undefined
|
||||||
this.create(this)
|
this.create(this)
|
||||||
this.sdk.addIncetance(this.options.id, this)
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
|
this.callback = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(that) {
|
async create(that) {
|
||||||
@ -24,17 +41,19 @@ class TextBox extends Base {
|
|||||||
// 创建textarea元素
|
// 创建textarea元素
|
||||||
var textarea = document.createElement('textarea');
|
var textarea = document.createElement('textarea');
|
||||||
textarea.className = 'textarea'
|
textarea.className = 'textarea'
|
||||||
|
textarea.value = that.options.text;
|
||||||
// 设置textarea的属性,例如行数和列数
|
// 设置textarea的属性,例如行数和列数
|
||||||
textarea.rows = 6;
|
textarea.rows = 6;
|
||||||
textarea.style.resize = 'none'
|
textarea.style.resize = 'none'
|
||||||
// 将textarea添加到div中
|
// 将textarea添加到div中
|
||||||
dom.appendChild(textarea);
|
dom.appendChild(textarea);
|
||||||
|
(!that.options.show) && (dom.style.display = 'none')
|
||||||
// 将div添加到body中
|
// 将div添加到body中
|
||||||
// document.body.appendChild(dom);
|
// document.body.appendChild(dom);
|
||||||
|
|
||||||
// 配置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(
|
||||||
@ -48,7 +67,8 @@ class TextBox extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewer.scene.postRender.addEventListener(that.handler);
|
viewer.scene.postRender.addEventListener(that.handler);
|
||||||
that.textDom = dom
|
that.textDom = dom;
|
||||||
|
|
||||||
}
|
}
|
||||||
async setHandeler(data) {
|
async setHandeler(data) {
|
||||||
let that = this
|
let that = this
|
||||||
@ -60,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
|
||||||
@ -81,6 +101,10 @@ class TextBox extends Base {
|
|||||||
that.sdk.viewer.scene.postRender.addEventListener(that.handler);
|
that.sdk.viewer.scene.postRender.addEventListener(that.handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async getwords(words) {
|
||||||
|
this.options.text = words
|
||||||
|
this.callback(this.options)
|
||||||
|
}
|
||||||
async returnFun() {
|
async returnFun() {
|
||||||
return this.handler
|
return this.handler
|
||||||
}
|
}
|
||||||
@ -91,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)
|
||||||
@ -118,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 }
|
||||||
@ -154,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)
|
||||||
|
|
||||||
|
@ -485,6 +485,7 @@ class YJEarth {
|
|||||||
_this.clickTextDom.removeEventListener('mousedown', mousedown);
|
_this.clickTextDom.removeEventListener('mousedown', mousedown);
|
||||||
document.removeEventListener('mousemove', mousemove);
|
document.removeEventListener('mousemove', mousemove);
|
||||||
document.removeEventListener('mouseup', mouseup);
|
document.removeEventListener('mouseup', mouseup);
|
||||||
|
_this.entityMap.get(_this.clickTextDom.id).getwords(_this.clickTextDom.getElementsByTagName('textarea')[0].value)
|
||||||
|
|
||||||
_this.clickTextDom.style['pointer-events'] = 'none'
|
_this.clickTextDom.style['pointer-events'] = 'none'
|
||||||
_this.clickTextDom = undefined
|
_this.clickTextDom = undefined
|
||||||
|
Reference in New Issue
Block a user