diff --git a/src/BaseDialog/index.js b/src/BaseDialog/index.js
index df9aab3..18b3f3c 100644
--- a/src/BaseDialog/index.js
+++ b/src/BaseDialog/index.js
@@ -1,5 +1,5 @@
class BaseDialog {
- constructor(container, options = {}) {
+ constructor(container, options = {}, only = true) {
this.container = container
this.options = { ...options }
this.options.ismove = true
@@ -9,10 +9,13 @@ class BaseDialog {
this.closeCallBack = options.closeCallBack
this._element = {}
this._element_style = undefined
+ this.only = only
}
async init() {
- this.closeAll()
+ if (this.only) {
+ this.closeAll()
+ }
DialogAll.push(this)
this.isDestroy = false
// body
@@ -48,6 +51,15 @@ class BaseDialog {
`
this._element.body.appendChild(this._element.foot)
+ let curtain = await document.createElement('div')
+ curtain.style.position = 'absolute'
+ curtain.style.top = '0'
+ curtain.style.left = '0'
+ curtain.style.width = '100%'
+ curtain.style.height = '100%'
+ curtain.style.backdropFilter = 'blur(2px)'
+ curtain.style.zIndex = '-999999'
+ this._element.body.appendChild(curtain)
// 关闭
let closeBtnsBox = this._element.body.getElementsByClassName('close-box')[0];
diff --git a/src/Draw/drawAttackArrow.js b/src/Draw/drawAttackArrow.js
index 0cd20a4..c9208e2 100644
--- a/src/Draw/drawAttackArrow.js
+++ b/src/Draw/drawAttackArrow.js
@@ -59,12 +59,17 @@ export default class DrawAttackArrow extends Draw {
return
}
into = '3D'
+ let pos84 = this.cartesian3Towgs84(cartesian, this.viewer)
+ let lastPos84 = cache_positions[cache_positions.length - 1]
+ if(lastPos84 && (lastPos84.lng === pos84.lng && lastPos84.lat === pos84.lat)) {
+ return
+ }
if (!this.entityHasCreated) {
let polyline_id = DrawAttackArrow.create_arrow_polygon(this)
this.points_ids.push(polyline_id)
}
this.points_ids.push(this.create_point(cartesian))
- cache_positions.push(this.cartesian3Towgs84(cartesian, this.viewer))
+ cache_positions.push(pos84)
isMove = false
})
this.event.mouse_right((movement, cartesian) => {
diff --git a/src/Draw/drawPolygon.js b/src/Draw/drawPolygon.js
index 84cbb9f..af9780a 100644
--- a/src/Draw/drawPolygon.js
+++ b/src/Draw/drawPolygon.js
@@ -13,6 +13,7 @@ class DrawPolygon extends Draw {
* */
constructor(sdk, options = {}) {
super(sdk, options)
+ this.color = options.color || 'rgba(255,0,0,0.5)'
this.polygonHasCreated = false
}
@@ -34,8 +35,8 @@ class DrawPolygon extends Draw {
positions: new Cesium.CallbackProperty((e) => {
return that.positions.concat(that.positions[0])
}),
- width: 2,
- material: Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5),
+ width: 3,
+ material: Cesium.Color.fromCssColorString(that.color).withAlpha(1),
clampToGround: true,
zIndex: 99999999
},
diff --git a/src/Global/MapPrint/index.js b/src/Global/MapPrint/index.js
index dd16630..43ba23c 100644
--- a/src/Global/MapPrint/index.js
+++ b/src/Global/MapPrint/index.js
@@ -1420,11 +1420,11 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
const url = URL.createObjectURL(blob);
let downloadElement = document.createElement('a');
downloadElement.href = url;
- downloadElement.download = `高清出图-${getDateTimeString()}.jpg`;
+ downloadElement.download = `高清出图-${getDateTimeString()}.png`;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
- }, 'image/jpeg', 0.95);
+ }, 'image/png', 0.95);
exporting = false;
exportBtn.innerHTML = '打印';
// canvas2.toBlob(function (blob) {
diff --git a/src/Global/MapX/index.js b/src/Global/MapX/index.js
index a96b34f..d16f0cd 100644
--- a/src/Global/MapX/index.js
+++ b/src/Global/MapX/index.js
@@ -124,7 +124,7 @@ function syncViewer() {
if (height > 9000000) {
height = 9000000
}
- if (height < 100000) {
+ if (height < 400000) {
this.entity.billboard.show = true
this.entity.rectangle.show = false
}
diff --git a/src/Global/MouseCoordinate/index.js b/src/Global/MouseCoordinate/index.js
index 0189c67..147f96a 100644
--- a/src/Global/MouseCoordinate/index.js
+++ b/src/Global/MouseCoordinate/index.js
@@ -4,18 +4,38 @@
import Tools from "../../Tools";
import { getCoordinateSystem } from "../../Global/global";
import MouseEvent from '../../Event/index'
+import { getSdk as get2DSdk } from '../../Global/MultiViewportMode'
+import { getSdk as getSplitScreenSdk } from "../../Global/SplitScreen";
let event
+let event2
let MouseCoordinateElm
let requestAnimationFrameEventId
+let tmovement
+let targetSdk
+let sdkD
const MouseCoordinate = (sdk, status) => {
+ if (!sdk || !sdk.viewer) {
+ return
+ }
+ targetSdk = sdk
+ sdkD = get2DSdk().sdkD
+ if(!sdkD) {
+ sdkD = getSplitScreenSdk().sdkD
+ }
+
let tools = new Tools(sdk)
if (status) {
if (event) {
event.destroy()
}
+ if (event2) {
+ event2.destroy()
+ event2 = undefined
+ }
event = new MouseEvent(sdk)
+ tmovement = null
let position = {
x: '',
y: '',
@@ -40,22 +60,60 @@ const MouseCoordinate = (sdk, status) => {
contentElm.style['background-size'] = `200% 200%`;
MouseCoordinateElm = contentElm
}
- sdk.viewer._element.appendChild(contentElm)
- let tmovement
+ sdk.viewer.container.appendChild(contentElm)
+
event.mouse_move((movement, cartesian) => {
- tmovement = { ...movement }
+ targetSdk = sdk
+ tmovement = { ...movement.endPosition }
})
const getPosition = () => {
- if(!tmovement) {
+ if (!targetSdk) {
return
}
let canvas = sdk.viewer._element.getElementsByTagName('canvas')[0]
- let left = tmovement.endPosition.x;
- let top = tmovement.endPosition.y;
- let cartesian = event.getcartesian(tmovement)
- contentElm.style['background-position-x'] = `${-canvas.width + left + 4}px`;
- contentElm.style['background-position-y'] = `${-canvas.height + top - 2}px`;
+ sdkD = get2DSdk().sdkD
+ if(!sdkD) {
+ sdkD = getSplitScreenSdk().sdkD
+ }
+ if (!event2 && sdkD) {
+ event2 = new MouseEvent(sdkD)
+ event2.mouse_move((movement, cartesian) => {
+ targetSdk = sdkD
+ tmovement = { x: movement.endPosition.x, y: movement.endPosition.y }
+ })
+ }
+ if (!tmovement) {
+ return
+ }
+ let left = tmovement.x;
+ let top = tmovement.y;
+ let cartesian
+ if (targetSdk.viewer.scene.mode === 2) {
+ left = left + canvas.width
+ cartesian = targetSdk.viewer.camera.pickEllipsoid(tmovement, targetSdk.viewer.scene.globe.ellipsoid)
+ }
+ else {
+ cartesian = targetSdk.viewer.scene.pickPosition(tmovement)
+ if (!cartesian) {
+ const ray = targetSdk.viewer.camera.getPickRay(position); //相交的射线
+ let pickedObjects = targetSdk.viewer.scene.drillPickFromRay(ray, 10);
+ let result = {}
+ for (let i = 0; i < pickedObjects.length; i++) {
+ if (pickedObjects[i].position) {
+ result = pickedObjects[i]
+ break
+ }
+ }
+ cartesian = result.position
+ if (!cartesian) {
+ cartesian = targetSdk.viewer.scene.globe.pick(ray, targetSdk.viewer.scene);
+ }
+ }
+ }
+ contentElm.style['background-position-x'] = `${-sdk.viewer.container.clientWidth + left + 4}px`;
+
+ contentElm.style['background-position-y'] = `${-sdk.viewer.container.clientHeight + top - 2}px`;
// this.entity.position = cartesian
if (cartesian) {
let degrees = tools.cartesian3Towgs84(cartesian, sdk.viewer)
@@ -97,10 +155,13 @@ const MouseCoordinate = (sdk, status) => {
else {
if (event) {
event.destroy()
- event = undefined
+ }
+ if (event2) {
+ event2.destroy()
+ event2 = undefined
}
if (MouseCoordinateElm) {
- sdk.viewer._element.removeChild(MouseCoordinateElm)
+ sdk.viewer.container.removeChild(MouseCoordinateElm)
MouseCoordinateElm = undefined
}
if (requestAnimationFrameEventId) {
diff --git a/src/Global/MultiViewportMode/index.js b/src/Global/MultiViewportMode/index.js
index 0d63e89..9e61089 100644
--- a/src/Global/MultiViewportMode/index.js
+++ b/src/Global/MultiViewportMode/index.js
@@ -49,7 +49,16 @@ async function init(sdk) {
sdk2D.viewer.imageryLayers.removeAll()
for (let i = 0; i < imageryLayers.length; i++) {
let entity = sdk2D.viewer.imageryLayers.addImageryProvider(imageryLayers[i].imageryProvider, imageryLayers[i]._layerIndex)
+ if(imageryLayers[i]._id) {
+ entity._id = imageryLayers[i]._id
+ }
entity.show = imageryLayers[i].show
+ entity.alpha = imageryLayers[i].alpha
+ if (imageryLayers[i]._objectState) {
+ if (imageryLayers[i]._showView == 3) {
+ entity.show = false
+ }
+ }
}
// sdk.viewer.entities.collectionChanged.addEventListener(syncEntities)
// sdk.viewer.dataSources.dataSourceAdded.addEventListener(syncDataSources)
@@ -61,6 +70,12 @@ async function init(sdk) {
JwwStatusSwitch(sdk2, true)
}
+ sdk.entityMap.forEach((item, key) => {
+ if (item.showView == 2) {
+ item.showView = 2
+ }
+ })
+
}
async function on(sdk) {
if (sdk2D) {
@@ -94,6 +109,11 @@ function off(sdk) {
activeViewer = null
syncObject = {}
}
+ sdk.entityMap.forEach((item, key) => {
+ if (item.showView) {
+ item.show = item.show
+ }
+ })
}
async function syncData2(sdk, id, entityId) {
@@ -119,7 +139,11 @@ async function syncData2(sdk, id, entityId) {
options.heightMode = 0
options.height = 0
}
- if (!that.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer')) {
+
+ if (!that.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer' && that.type !== 'wallStereoscopic')) {
+ if (that.showView == 3) {
+ options.show = false
+ }
let newObject = await new that.constructor(sdk2D, options)
newObject.onClick = that.onClick
newObject.onRightClick = that.onRightClick
@@ -207,8 +231,15 @@ async function syncData2(sdk, id, entityId) {
obj.options.heightReference = 1
}
let options = syncObject.tools.deepCopyObj(obj.options)
- if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer')) {
- let target = await new obj.constructor(sdk2D, options)
+ if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer' && obj.type !== 'wallStereoscopic')) {
+ if (obj.showView == 3) {
+ options.show = false
+ }
+ let target = await sdk2D.entityMap.get(options.id)
+ if(target) {
+ await target.remove()
+ }
+ target = await new obj.constructor(sdk2D, options)
target.onClick = obj.onClick
target.onRightClick = obj.onRightClick
target.onMouseMove = obj.onMouseMove
@@ -401,11 +432,25 @@ function syncImageryLayerRemoved(layer, index) {
sdk2D.viewer.imageryLayers.remove(layer2d)
}
function syncImageryLayerShownOrHidden(layer, index, state) {
+ return
let layer2d = sdk2D.viewer.imageryLayers._layers[index]
+ let layer3d = sdk3D.viewer.imageryLayers._layers[index]
+ console.log('layer2d', layer2d, sdk2D, layer3d)
+
if (!layer2d) {
return
}
- layer2d.show = state
+ if (layer3d._objectState) {
+ if (!layer3d._showView || layer3d._showView == 2) {
+ layer2d.show = true
+ }
+ if (layer3d._showView == 3) {
+ layer2d.show = false
+ }
+ }
+ else {
+ layer2d.show = state
+ }
}
async function syncPrimitives(primitive) {
@@ -535,6 +580,7 @@ function syncViewer() {
}
+
function get2DView() {
return sdk2D
}
diff --git a/src/Global/SplitScreen/index.js b/src/Global/SplitScreen/index.js
index 8df76aa..845b6ee 100644
--- a/src/Global/SplitScreen/index.js
+++ b/src/Global/SplitScreen/index.js
@@ -517,7 +517,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) {
thatD.textShow = thatP.textShow
}
if (thatP.label && thatP.labelShow) {
- thatP.label.entity.show = true
+ thatP.labelShow = true
}
if (thatD.label) {
thatD.label.options.ground = false
diff --git a/src/Global/mouseRightMenu/index.js b/src/Global/mouseRightMenu/index.js
index 0fd350e..8b9a223 100644
--- a/src/Global/mouseRightMenu/index.js
+++ b/src/Global/mouseRightMenu/index.js
@@ -121,6 +121,9 @@ function MouseRightMenu(sdk, status, callBack) {
+
${addedMenu}
`
_element.appendChild(menuElm)
@@ -175,6 +178,7 @@ function MouseRightMenu(sdk, status, callBack) {
break
case '文本框':
object.position = position
+ key = 'textBox'
break
}
eventListener[sdk.div_id].callBack(key, object)
diff --git a/src/Measure/MeasureDistance/index.js b/src/Measure/MeasureDistance/index.js
index 7bb3749..52755af 100644
--- a/src/Measure/MeasureDistance/index.js
+++ b/src/Measure/MeasureDistance/index.js
@@ -91,7 +91,7 @@ class MeasureDistance extends Measure {
//暂时固定取20个点
- if (d > 20) {//大于20m时,固定取20个点
+ if (d > 2) {//大于20m时,固定取20个点
meters = d / 20
await start(meters)
} else if (d < 1) {
@@ -106,8 +106,8 @@ class MeasureDistance extends Measure {
async sampleHeight(p1, index) {
- let p2 = await this.sampleHeightMostDetailed([p1])
- p1.alt = p2[0].height
+ let height = await this.getClampToHeight(p1, [...this.sdk.viewer.entities.values])
+ p1.alt = height
return {position: p1, index}
}
diff --git a/src/Obj/Analysis/Contour/index.js b/src/Obj/Analysis/Contour/index.js
index 6a246f9..56f8dff 100644
--- a/src/Obj/Analysis/Contour/index.js
+++ b/src/Obj/Analysis/Contour/index.js
@@ -47,6 +47,11 @@ class ContourAnalysis {
YJ.Analysis.AnalysesResults.push(this)
this.createNewLine();
}
+
+ get type() {
+ return 'ContourAnalysis'
+ }
+
createNewLine() {
ContourAnalysis.interpolatePoint(this);
}
diff --git a/src/Obj/Analysis/Visibility/index.js b/src/Obj/Analysis/Visibility/index.js
index a7e44cd..0f115ce 100644
--- a/src/Obj/Analysis/Visibility/index.js
+++ b/src/Obj/Analysis/Visibility/index.js
@@ -63,11 +63,15 @@ class VisibilityAnalysis extends Tools {
that.tip.set_text("左键创建视角终点,右键结束通视分析")
if (!that.resultObject.viewPoint) {
let pos84 = that.cartesian3Towgs84(cartesian, that.viewer)
- let positions = await Cesium.sampleTerrainMostDetailed(
- that.sdk.viewer.terrainProvider,
- [Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)]
- );
- if (positions[0].height > pos84.alt) {
+ let positions
+ if(that.sdk.viewer.terrainProvider.availability)
+ {
+ positions = await Cesium.sampleTerrainMostDetailed(
+ that.sdk.viewer.terrainProvider,
+ [Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)]
+ );
+ }
+ if (positions && positions[0].height > pos84.alt) {
pos84.alt = positions[0].height
}
pos84.alt = pos84.alt + that.viewPointHeight
diff --git a/src/Obj/Base/AssembleObject/index.js b/src/Obj/Base/AssembleObject/index.js
index e04f065..3ee6ba0 100644
--- a/src/Obj/Base/AssembleObject/index.js
+++ b/src/Obj/Base/AssembleObject/index.js
@@ -40,7 +40,7 @@ class AssembleObject extends Base {
this.options.positions = options.positions || []
this.options.line = options.line || {}
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
- this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)'
+ this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
this.options['area-unit'] = options['area-unit'] || '平方米'
this.entity
this.event = new MouseEvent(this.sdk)
diff --git a/src/Obj/Base/AttackArrowObject/index.js b/src/Obj/Base/AttackArrowObject/index.js
index c3aaaac..ec83033 100644
--- a/src/Obj/Base/AttackArrowObject/index.js
+++ b/src/Obj/Base/AttackArrowObject/index.js
@@ -40,7 +40,7 @@ class AttackArrowObject extends Base {
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
this.options.line = options.line || {}
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
- this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)'
+ this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
this.options['area-unit'] = options['area-unit'] || '平方米'
this.entity
this.event = new MouseEvent(this.sdk)
diff --git a/src/Obj/Base/BaseSource/BaseLayer/index.js b/src/Obj/Base/BaseSource/BaseLayer/index.js
index f4a0a79..083fd74 100644
--- a/src/Obj/Base/BaseSource/BaseLayer/index.js
+++ b/src/Obj/Base/BaseSource/BaseLayer/index.js
@@ -9,7 +9,7 @@
import Dialog from '../../../Element/Dialog';
import CoordTransform from "../../../../transform/CoordTransform";
import BaseSource from "../index";
-import { syncData } from '../../../../Global/MultiViewportMode'
+import { syncData, get2DView } from '../../../../Global/MultiViewportMode'
import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen'
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
@@ -244,8 +244,19 @@ class BaseLayer extends BaseSource {
this.originalOptions = this.deepCopyObj(this.options)
this._DialogObject.close()
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
- syncData(this.sdk, this.options.id)
+ // syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
+ let sdk2D = get2DView()
+ if (sdk2D && sdk2D != this.sdk) {
+ for(let i=0;i {
this.reset()
diff --git a/src/Obj/Base/BaseSource/BaseModel/Model/_element.js b/src/Obj/Base/BaseSource/BaseModel/Model/_element.js
index 9301b0f..1385d7a 100644
--- a/src/Obj/Base/BaseSource/BaseModel/Model/_element.js
+++ b/src/Obj/Base/BaseSource/BaseModel/Model/_element.js
@@ -56,7 +56,7 @@ function html(that) {
- 固定大小
+ 固定大小
diff --git a/src/Obj/Base/BaseSource/BaseTerrain/index.js b/src/Obj/Base/BaseSource/BaseTerrain/index.js
index 0d2336c..9f9a087 100644
--- a/src/Obj/Base/BaseSource/BaseTerrain/index.js
+++ b/src/Obj/Base/BaseSource/BaseTerrain/index.js
@@ -8,7 +8,7 @@
import Dialog from '../../../Element/Dialog';
import { getHost } from "../../../../on";
import BaseSource from "../index";
-import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
+import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen'
class BaseTerrain extends BaseSource {
@@ -78,6 +78,11 @@ class BaseTerrain extends BaseSource {
close() {
this.sdk.viewer.scene.terrainProvider =
new Cesium.EllipsoidTerrainProvider({})
+ for (let i = 0; i < YJ.Analysis.AnalysesResults.length; i++) {
+ if (YJ.Analysis.AnalysesResults[i].type === 'ContourAnalysis') {
+ YJ.Analysis.AnalysesResults[i].destroy()
+ }
+ }
syncSplitData(this.sdk, this.options.id)
clearTimeout(this.#updateModelTimeout)
@@ -156,7 +161,7 @@ class BaseTerrain extends BaseSource {
}
setActiveViewer(0)
closeRotateAround(this.sdk)
- closeViewFollow(this.sdk)
+ closeViewFollow(this.sdk)
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
let orientation = {
diff --git a/src/Obj/Base/BillboardObject/index.js b/src/Obj/Base/BillboardObject/index.js
index 053a51c..98f8857 100644
--- a/src/Obj/Base/BillboardObject/index.js
+++ b/src/Obj/Base/BillboardObject/index.js
@@ -40,6 +40,11 @@ import {
import { getGoodsList } from '../../../Tools/getGoodsList'
class BillboardObject extends Base {
+ #_postRenderEvent = null
+ #_destroyMouseEvent = null
+ #_billboardHeight = 0
+
+
/**
* @constructor
* @description 创建点标注
@@ -118,6 +123,7 @@ class BillboardObject extends Base {
this.options.positions.alt = Number(
Number(options.positions.alt || 0).toFixed(2)
)
+ this.#_billboardHeight = this.options.positions.alt
// this.options.diffuseShow = options.diffuseShow || false
// this.options.diffuseRadius = (options.diffuseRadius || options.diffuseRadius === 0) ? options.diffuseRadius : 10
// this.options.diffuseDuration = (options.diffuseDuration || options.diffuseDuration === 0) ? options.diffuseDuration : 2000
@@ -145,11 +151,18 @@ class BillboardObject extends Base {
this.options.attribute.goods.content || []
this.options.attributeType = options.attributeType || 'richText'
this.options.coordinate = options.coordinate || ''
+ this.options.attributeBoxState = options.attributeBoxState || false
this.operate = {}
this._elms = {}
this.previous = {
positions: { ...this.options.positions }
}
+ this.options.attributePos = options.attributePos || {
+ x: 60,
+ y: 60,
+ width: 200,
+ height: 120
+ }
this.entity
this._proj = this.sdk.proj
@@ -182,7 +195,108 @@ class BillboardObject extends Base {
+ this.#_destroyMouseEvent = () => {
+ this.attributeElm && (this.attributeElm.style.pointerEvents = 'unset')
+ this.sdk.viewer._element.onmousemove = null
+ document.removeEventListener('mouseup', this.#_destroyMouseEvent)
+ document.removeEventListener('mouseleave', this.#_destroyMouseEvent)
+ }
+ this.#_postRenderEvent = () => {
+ let siteInfoPosition = Cesium.Cartesian3.fromDegrees(
+ this.options.positions.lng,
+ this.options.positions.lat,
+ this.#_billboardHeight
+ )
+ if (this.attributeElm && this.entity) {
+ let winpos = this.sdk.viewer.scene.cartesianToCanvasCoordinates(
+ siteInfoPosition
+ )
+ let pixelOffset = this.entity.label.pixelOffset.getValue()
+ if (winpos) {
+ let scale = getCurrentBillboardScale(this.entity, this.sdk.viewer.scene)
+ let height = ((this.entity.billboard.height.getValue() * (this.options.billboard.scale || 0)) + this.options.label.fontSize) * (1 - (scale * scale))
+ let flag = false
+ let lineElm = this.attributeElm.getElementsByClassName('billboard-attribute-box-line')[0]
+ let leftTopElm = this.attributeElm.getElementsByClassName('left-top')[0]
+ let rightTopElm = this.attributeElm.getElementsByClassName('right-top')[0]
+ this.attributeElm.style.left = (winpos.x + this.options.attributePos.x).toFixed(0) + 'px'
+ this.attributeElm.style.top = (winpos.y + pixelOffset.y - (this.options.label.show ? (this.options.label.fontSize / 2) : -(this.options.label.fontSize / 2)) - this.attributeElm.offsetHeight - this.options.attributePos.y + height).toFixed(0) + 'px'
+ this.attributeElm.style.width = this.options.attributePos.width + 'px'
+ this.attributeElm.style.height = this.options.attributePos.height + 'px'
+ if (this.options.attributePos.x < -this.options.attributePos.width / 2) {
+ flag = true
+ lineElm.style.left = 'unset'
+ lineElm.style.right = '0'
+ leftTopElm.style.display = 'block'
+ rightTopElm.style.display = 'none'
+ }
+ else {
+ lineElm.style.left = '0'
+ lineElm.style.right = 'unset'
+ leftTopElm.style.display = 'none'
+ rightTopElm.style.display = 'block'
+ }
+
+ let lineLength
+ let lineAngleRad
+ let lineAngle
+ let x
+ let y
+ if (flag) {
+ x = this.attributeElm.offsetWidth + this.options.attributePos.x
+ y = this.options.attributePos.y ? this.options.attributePos.y : 0
+ }
+ else {
+ x = this.options.attributePos.x
+ y = this.options.attributePos.y ? this.options.attributePos.y : 0
+ }
+ lineLength = Math.sqrt((x * x) + (y * y)).toFixed(2);
+ lineAngleRad = Math.atan(x / y);
+ lineAngle = parseFloat((lineAngleRad * 180 / Math.PI).toFixed(2));
+ if (this.options.attributePos.y < 0) {
+ lineAngle = lineAngle + 180
+ }
+ // if(this.options.attributePos.y<-this.options.attributePos.height/2) {
+ // lineElm.style.bottom = 'unset'
+ // lineElm.style.top = '0'
+ // }
+ // else {
+ // lineElm.style.bottom = -lineLength + 'px'
+ // lineElm.style.top = 'unset'
+ // }
+ lineElm.style.height = lineLength + 'px'
+ lineElm.style.transform = 'rotate(' + lineAngle + 'deg)'
+ }
+ }
+ }
+
+ function getCurrentBillboardScale(entity, scene) {
+ // 获取相机到Billboard的距离
+ const distance = Cesium.Cartesian3.distance(
+ scene.camera.positionWC,
+ entity.position.getValue()
+ );
+ // 获取缩放距离配置
+ const scaleByDistance = entity.billboard.scaleByDistance ? entity.billboard.scaleByDistance.getValue() : undefined;
+
+ if (!scaleByDistance) {
+ // 如果没有设置距离缩放,则使用基础缩放值
+ return 1.0;
+ }
+
+ // 解析缩放距离参数 [near, nearScale, far, farScale]
+ const { near, nearValue, far, farValue } = scaleByDistance;
+ if (distance <= near) {
+ return nearValue;
+ } else if (distance >= far) {
+ return farValue;
+ } else {
+ // 计算中间距离的缩放值(线性插值)
+ const t = (distance - near) / (far - near);
+ return Cesium.Math.lerp(nearValue, farValue, t);
+ }
+ }
this.sdk.addIncetance(this.options.id, this)
@@ -243,6 +357,7 @@ class BillboardObject extends Base {
that.entity.billboard.imgHeight = 0
that.entity.billboard.image = canvas
addCluster(that.sdk, that.entity)
+ that.attributeBoxState && (that.attributeBoxState = true)
}
return
}
@@ -267,13 +382,14 @@ class BillboardObject extends Base {
return img
}, false)
addCluster(that.sdk, that.entity)
+ that.attributeBoxState && (that.attributeBoxState = true)
}
})
}
else {
let image = new Image()
image.src =
- url ||
+ url ||
that.getSourceRootPath() + '/img/A-ablu-blank.png'
switch (that.options.heightMode) {
case 2:
@@ -298,6 +414,7 @@ class BillboardObject extends Base {
that.entity.billboard.imgHeight = height
that.entity.billboard.image = canvas
addCluster(that.sdk, that.entity)
+ that.attributeBoxState && (that.attributeBoxState = true)
}
}
image.onerror = function (err) {
@@ -309,6 +426,7 @@ class BillboardObject extends Base {
that.entity.billboard.imgHeight = 0
that.entity.billboard.image = canvas
addCluster(that.sdk, that.entity)
+ that.attributeBoxState && (that.attributeBoxState = true)
}
};
}
@@ -465,14 +583,45 @@ class BillboardObject extends Base {
return this.options.show
}
set show(v) {
- this.options.show = v
- this.originalOptions.show = v
- this.entity && (this.entity.show = v)
+ if (!this.isShowView) {
+ this.options.show = v
+ this.originalOptions.show = v
+ }
+ if (!this.showView || this.showView == 3) {
+ this.entity && (this.entity.show = this.options.show)
+ if (this.attributeBoxState && this.options.show) {
+ this.attributeBoxState = this.options.show
+ }
+ else {
+ // 关闭属性框
+ document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ if (this.attributeElm) {
+ this.sdk.viewer._element.removeChild(this.attributeElm)
+ this.attributeElm = null
+ }
+ this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent)
+ }
+ }
+ else {
+ this.entity && (this.entity.show = false)
+ // 关闭属性框
+ document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ if (this.attributeElm) {
+ this.sdk.viewer._element.removeChild(this.attributeElm)
+ this.attributeElm = null
+ }
+ this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent)
+ }
syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
+
if (this._DialogObject && this._DialogObject.showBtn) {
- this._DialogObject.showBtn.checked = v
+ this._DialogObject.showBtn.checked = this.options.show
}
+
+ this.isShowView = false
// if (v) {
// if (this.diffuseShow) {
// this.diffuseShow = true
@@ -552,6 +701,26 @@ class BillboardObject extends Base {
if (this.entity) {
this.entity.billboard.heightReference = heightMode
this.entity.label.heightReference = heightMode
+ if(heightMode == Cesium.HeightReference.CLAMP_TO_GROUND) {
+ if (this.sdk.viewer.scene.terrainProvider.availability) {
+ Cesium.sampleTerrainMostDetailed(
+ this.sdk.viewer.scene.terrainProvider,
+ [
+ Cesium.Cartographic.fromDegrees(
+ this.options.positions.lng,
+ this.options.positions.lat
+ )
+ ]
+ ).then(position => {
+ this.#_billboardHeight = position[0].height
+ })
+ } else {
+ this.#_billboardHeight = 0
+ }
+ }
+ else {
+ this.#_billboardHeight = this.options.positions.alt
+ }
}
this._elms.heightMode && (this._elms.heightMode.value = heightModeName)
}
@@ -606,6 +775,7 @@ class BillboardObject extends Base {
}
set alt(v) {
this.options.positions.alt = Number(Number(v).toFixed(2))
+ this.#_billboardHeight = this.options.positions.alt
// this.scan && (this.scan.alt = v)
// this.diffuse && (this.diffuse.alt = v)
this.renewPoint()
@@ -766,6 +936,8 @@ class BillboardObject extends Base {
_this._frameImages = []
superGif.load(function (status) {
if (status == 404) {
+ let width = 31
+ let height = 36
canvas = document.createElement('canvas')
canvas.width = 0
canvas.height = 0
@@ -855,6 +1027,8 @@ class BillboardObject extends Base {
billboardH = height * (31 / width)
}
image.onerror = function (err) {
+ let width = 31
+ let height = 36
canvas.width = 0
canvas.height = 0
billboardH = 0
@@ -1702,6 +1876,22 @@ class BillboardObject extends Base {
this.cameraSelect && this.cameraSelect()
this.ISCSelect && this.ISCSelect()
this.goodsSelect && this.goodsSelect()
+
+ let col = document.createElement('div')
+ col.className = 'col'
+ col.style.flex = '0 0 110px'
+ col.innerHTML = `
+ 属性框
+
+ `
+
+ let row = this._DialogObject._element.content.getElementsByClassName('attribute')[0].getElementsByClassName('row')[0]
+ row.appendChild(col)
+ let boxSwitch = col.getElementsByClassName('btn-switch')[0]
+ boxSwitch.checked = this.attributeBoxState
+ boxSwitch.addEventListener('change', (e) => {
+ this.attributeBoxState = boxSwitch.checked
+ })
let tagData = this.attributeSelect
let attributeElm = this._DialogObject._element.content.getElementsByClassName(
'attribute-select-box'
@@ -2213,6 +2403,7 @@ class BillboardObject extends Base {
this.attributeCamera = this.options.attribute.camera.content
this.attributeGoods = this.options.attribute.goods.content
this.attributeISC = this.options.attribute.ISC.content
+ this.attributeBoxState = this.options.attributeBoxState
this.cameraSelect && this.cameraSelect()
this.goodsSelect && this.goodsSelect()
}
@@ -2220,6 +2411,7 @@ class BillboardObject extends Base {
async remove() {
await remove_entity_from_cluster(this.sdk.viewer, this.entity)
this.entity = null
+ this.attributeBoxState = false
if (!this.sdk.viewer || !this.sdk.viewer.entities) {
return
}
@@ -2344,6 +2536,9 @@ class BillboardObject extends Base {
}
async updateHeight() {
+ if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.scene) {
+ return
+ }
let height
let height2
let point1 = new Cesium.Cartesian3.fromDegrees(
@@ -2422,6 +2617,7 @@ class BillboardObject extends Base {
switch (this._elms.heightMode.value) {
case '海拔高度':
heightElm.value = this.options.positions.alt
+ this.#_billboardHeight = this.options.positions.alt
break
case '相对地表':
if (this.sdk.viewer.scene.terrainProvider.availability) {
@@ -2437,15 +2633,18 @@ class BillboardObject extends Base {
heightElm.value = Number(
(this.options.positions.alt - position[0].height).toFixed(2)
)
+ this.#_billboardHeight = this.options.positions.alt
})
} else {
heightElm.value = this.options.positions.alt
+ this.#_billboardHeight = this.options.positions.alt
}
break
case '依附地表':
break
case '依附模型':
heightElm.value = this.options.positions.alt
+ this.#_billboardHeight = this.options.positions.alt
break
}
}
@@ -2719,6 +2918,216 @@ class BillboardObject extends Base {
(this.originalOptions.customView = this.options.customView)
}
}
+
+ get attributeBoxState() {
+ return this.options.attributeBoxState
+ }
+
+ set attributeBoxState(state) {
+ state = state ? true : false
+ this.options.attributeBoxState = state
+ document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ if (this.attributeElm) {
+ this.sdk.viewer._element.removeChild(this.attributeElm)
+ this.attributeElm = null
+ }
+ this.sdk.viewer.scene.postRender.removeEventListener(this.#_postRenderEvent)
+ if (state && this.sdk && this.sdk.viewer && this.sdk.viewer._element && this.show) {
+ let attributeElm = document.createElement('div')
+ this.attributeElm = attributeElm
+ attributeElm.className = 'billboard-attribute-box'
+ attributeElm.style.top = '0px'
+ attributeElm.style.left = '0px'
+ attributeElm.style.width = 0
+ attributeElm.style.height = 0
+ // attributeElm.innerHTML = this.options.richTextContent
+ this.sdk.viewer._element.appendChild(attributeElm)
+ let linkHtml = ''
+ let goodsHtml = ''
+ let richTextHtml = ''
+ for (let i = 0; i < this.options.attribute.link.content.length; i++) {
+ linkHtml += ``
+ }
+ if (this.options.attribute.goods && this.options.attribute.goods.content && this.options.attribute.goods.content.length > 0) {
+ goodsHtml += `
+
+
+
+ `
+ for (let i = 0; i < this.options.attribute.goods.content.length; i++) {
+ goodsHtml += `
+
${i + 1}
+
${this.options.attribute.goods.content[i].name}
+
${this.options.attribute.goods.content[i].cnt}
+
`
+ }
+ goodsHtml += `
`
+ }
+ if (this.options.richTextContent) {
+ richTextHtml = `
+ ${this.options.richTextContent}
+ `
+ }
+
+ let boxHtml = `
+
+
+ `
+
+ if (!linkHtml && !goodsHtml && !richTextHtml) {
+ boxHtml = boxHtml + '暂无属性信息
'
+ }
+ else {
+ boxHtml = boxHtml + `
+
+ ${richTextHtml}
+ ${goodsHtml}
+ ${linkHtml}
+
+ `
+ }
+
+ attributeElm.innerHTML = boxHtml
+
+ if (attributeElm.getElementsByClassName('tabs')[0]) {
+ let tabsElm = new cy_tabs(attributeElm.getElementsByClassName('tabs')[0], undefined, this.sdk)
+ }
+
+ let imgElm = attributeElm.getElementsByTagName('img')
+ for (let i = 0; i < imgElm.length; i++) {
+ if (!imgElm[i].style.width) {
+ imgElm[i].style.width = '100%'
+ }
+ }
+
+ this.sdk.viewer.scene.postRender.addEventListener(this.#_postRenderEvent)
+ let leftOnmousedown = (e) => {
+ if (this.options.attributePos.width < 200) {
+ this.options.attributePos.width = 200
+ }
+ if (this.options.attributePos.height < 120) {
+ this.options.attributePos.height = 120
+ }
+ let x = e.x
+ let y = e.y
+ let width = this.options.attributePos.width
+ let height = this.options.attributePos.height
+ let positionx = this.options.attributePos.x
+ this.sdk.viewer._element.onmousemove = (e2) => {
+ this.options.attributePos.width = width + (x - e2.x)
+ this.options.attributePos.height = height + (y - e2.y)
+ if (this.options.attributePos.width < 200) {
+ this.options.attributePos.width = 200
+ }
+ else {
+ this.options.attributePos.x = positionx - (x - e2.x)
+ }
+ if (this.options.attributePos.height < 120) {
+ this.options.attributePos.height = 120
+ }
+ // this.options.attributePos.y = positiony + (y - e2.y)
+ }
+ document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ }
+ let rightOnmousedown = (e) => {
+ let x = e.x
+ let y = e.y
+ if (this.options.attributePos.width < 200) {
+ this.options.attributePos.width = 200
+ }
+ if (this.options.attributePos.height < 120) {
+ this.options.attributePos.height = 120
+ }
+ let width = this.options.attributePos.width
+ let height = this.options.attributePos.height
+ this.sdk.viewer._element.onmousemove = (e2) => {
+ this.options.attributePos.width = width + (e2.x - x)
+ this.options.attributePos.height = height + (y - e2.y)
+ }
+ document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ }
+ // leftTopElm.onmousedown = (e) => {
+ // console.log(1111111111)
+ // if (this.options.attributePos.width < 200) {
+ // this.options.attributePos.width = 200
+ // }
+ // if (this.options.attributePos.height < 120) {
+ // this.options.attributePos.height = 120
+ // }
+ // let x = e.x
+ // let y = e.y
+ // let width = this.options.attributePos.width
+ // let height = this.options.attributePos.height
+ // let positionx = this.options.attributePos.x
+ // this.sdk.viewer._element.onmousemove = (e2) => {
+ // this.options.attributePos.width = width + (x - e2.x)
+ // this.options.attributePos.height = height + (y - e2.y)
+ // if (this.options.attributePos.width < 200) {
+ // this.options.attributePos.width = 200
+ // }
+ // else {
+ // this.options.attributePos.x = positionx - (x - e2.x)
+ // }
+ // if (this.options.attributePos.height < 120) {
+ // this.options.attributePos.height = 120
+ // }
+ // // this.options.attributePos.y = positiony + (y - e2.y)
+ // }
+ // document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ // document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ // }
+ // rightTopElm.onmousedown = (e) => {
+ // let x = e.x
+ // let y = e.y
+ // if (this.options.attributePos.width < 200) {
+ // this.options.attributePos.width = 200
+ // }
+ // if (this.options.attributePos.height < 120) {
+ // this.options.attributePos.height = 120
+ // }
+ // let width = this.options.attributePos.width
+ // let height = this.options.attributePos.height
+ // this.sdk.viewer._element.onmousemove = (e2) => {
+ // this.options.attributePos.width = width + (e2.x - x)
+ // this.options.attributePos.height = height + (y - e2.y)
+ // }
+ // document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ // document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ // }
+
+ attributeElm.onmousedown = (e) => {
+ attributeElm.style.pointerEvents = 'none'
+ if (e.target.className.indexOf('left-top') != -1) {
+ leftOnmousedown(e)
+ }
+ else if (e.target.className.indexOf('right-top') != -1) {
+ rightOnmousedown(e)
+ }
+ else {
+ let x = e.x
+ let y = e.y
+ let oldX = this.options.attributePos.x
+ let oldXY = this.options.attributePos.y
+ let height = this.options.attributePos.height
+ this.sdk.viewer._element.onmousemove = (e2) => {
+ this.options.attributePos.x = oldX + (e2.x - x)
+ this.options.attributePos.y = oldXY - (e2.y - y)
+ }
+ document.addEventListener('mouseup', this.#_destroyMouseEvent);
+ document.addEventListener('mouseleave', this.#_destroyMouseEvent);
+ }
+ }
+ }
+ }
}
export default BillboardObject
diff --git a/src/Obj/Base/CircleDiffuse/index.js b/src/Obj/Base/CircleDiffuse/index.js
index be4646d..36acfa4 100644
--- a/src/Obj/Base/CircleDiffuse/index.js
+++ b/src/Obj/Base/CircleDiffuse/index.js
@@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
import richText from "../../Element/richText";
import MouseEvent from '../../../Event/index'
import LabelObject from '../LabelObject'
-import { syncData } from '../../../Global/MultiViewportMode'
+import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
import { legp } from '../../Element/datalist';
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
import MouseTip from '../../../MouseTip'
@@ -223,16 +223,31 @@ class CircleDiffuse extends Base {
set show(v) {
if (typeof v === "boolean") {
- this.options.show = v
- this.entity.show = v
+ let sdkD = get2DSdk().sdkD
+ if (!this.isShowView || !sdkD) {
+ this.options.show = v
+ }
+ if (!this.showView || this.showView == 3 || !sdkD) {
+ this.entity.show = this.options.show
+ if (this.options.label.show) {
+ this.label.show = this.options.show
+ }
+ }
+ else {
+ this.entity.show = false
+ if (this.options.label.show) {
+ this.label.show = false
+ }
+ }
+
+ this.isShowView = false
+
syncData(this.sdk, this.options.id)
syncSplitData(this.sdk, this.options.id)
if (this._DialogObject && this._DialogObject.showBtn) {
this._DialogObject.showBtn.checked = v
}
- if (this.options.label.show) {
- this.label.show = v
- }
+
} else {
console.error("参数必须为boolean")
}
@@ -362,6 +377,7 @@ class CircleDiffuse extends Base {
return this.options.circle
}
set circle(v) {
+ console.log(v)
this.options.circle = v || [{ radius: 10 }]
for (let i = 0; i < this.options.circle.length; i++) {
if(this.options.circle[i].radius>999999) {
@@ -427,8 +443,9 @@ class CircleDiffuse extends Base {
return this.options.label.show
}
set labelShow(v) {
+ let sdkD = get2DSdk().sdkD
this.options.label.show = v
- if (this.show) {
+ if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
this.label.show = v
}
else {
@@ -1321,7 +1338,7 @@ class CircleDiffuse extends Base {
}
async remove() {
- this.label.remove()
+ this.label && this.label.remove()
this.entity && this.sdk.viewer.entities.remove(this.entity)
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
this.entity = null
@@ -1405,7 +1422,7 @@ class CircleDiffuse extends Base {
}
}
this._radius = radius
- inputElm.value = value
+ // inputElm.value = value
CircleDiffuse.create(this)
}
}
diff --git a/src/Obj/Base/CircleObject/index.js b/src/Obj/Base/CircleObject/index.js
index a6e88d1..d85022b 100644
--- a/src/Obj/Base/CircleObject/index.js
+++ b/src/Obj/Base/CircleObject/index.js
@@ -45,7 +45,7 @@ class CircleObject extends Base {
this.options.center = options.center || {}
this.options.line = options.line || {}
this.options.line.width = ((this.options.line.width || this.options.line.width === 0) ? this.options.line.width : 3)
- this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 0.5)'
+ this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
this.options['area-unit'] = options['area-unit'] || '平方米'
options.label = options.label || {}
this._elms = {};
@@ -333,7 +333,7 @@ class CircleObject extends Base {
}
set labelShow(v) {
this.options.label.show = v
- if (this.show) {
+ if (this.show && (!this.showView || this.showView == 3)) {
this.label.show = v
}
else {
diff --git a/src/Obj/Base/CurvelineObject/index.js b/src/Obj/Base/CurvelineObject/index.js
index aec879c..0f632a0 100644
--- a/src/Obj/Base/CurvelineObject/index.js
+++ b/src/Obj/Base/CurvelineObject/index.js
@@ -30,7 +30,7 @@ class CurvelineObject extends Base {
* @param options.heightMode{number} 高度模式(0:海拔高度;1:相对高度;2:依附模式)
* @param options['nose-to-tail']=false {boolean} 首尾相连
* @param options.extend=false {boolean} 线缓冲
- * @param options['extend-width']=1 {number} 线缓冲宽度
+ * @param options['extend-width']=10 {number} 线缓冲宽度
* @param options['extend-color']=#ffde00 {number} 线缓冲颜色
* @param options.show=true {boolean} 显隐
* @param {Array.