Compare commits
192 Commits
0cf59afffd
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c9ab02e3fc | |||
| db0d907e40 | |||
| 2b57f8be2f | |||
| 7cf0a0a650 | |||
| 7e6b6c0fca | |||
| df2c1735bc | |||
| 3ae330df3b | |||
| 7ba25619b7 | |||
| ae0dad068b | |||
| d1dd920fd2 | |||
| a69034a18e | |||
| 7fc4f14756 | |||
| feff8c3a76 | |||
| 58b8c6a897 | |||
| 349c91f8df | |||
| 92ef4a68fd | |||
| 623a220cbf | |||
| e8258d96d0 | |||
| d0a682f233 | |||
| 65441ddff4 | |||
| 7f3b04eb08 | |||
| 9289d08f24 | |||
| f9a3ffb359 | |||
| f5d915bd58 | |||
| 91cc200917 | |||
| 0c4c956868 | |||
| 838f39ba40 | |||
| 077170f2d4 | |||
| a1e33d907d | |||
| 57a9ccacbd | |||
| 0eef08ce45 | |||
| 0f9ad0a0f0 | |||
| c6f3138e25 | |||
| 819166bae0 | |||
| 159ade36f0 | |||
| f8443b7f62 | |||
| 7feab0786a | |||
| 5ceaa3b649 | |||
| 9f216b7257 | |||
| 4247327bfa | |||
| 1856bc85e3 | |||
| dff3739a0f | |||
| 53d2f06918 | |||
| cb2741862a | |||
| ce065fb845 | |||
| f37f95d646 | |||
| 6117e74a44 | |||
| ec41c867d4 | |||
| a7a743a394 | |||
| fb2681fdbe | |||
| 427b38a6c3 | |||
| b5e21fec3c | |||
| 1a1aa9f6a5 | |||
| 1229226e8f | |||
| 979a285295 | |||
| 18cec0d742 | |||
| 1ea59d0f8a | |||
| 2d1bc61cca | |||
| 5f6211a01d | |||
| 97c0d13a88 | |||
| 8618508d3f | |||
| dd213e8337 | |||
| a293246c07 | |||
| 9d1c25e8ef | |||
| c08dfb0f85 | |||
| 15460702f9 | |||
| 2c27391058 | |||
| 80869050e1 | |||
| 8025a298a2 | |||
| 0f518ef6cb | |||
| 1af43bb6a9 | |||
| ea80fe325c | |||
| e8e1e320b3 | |||
| 4f0c0ca76d | |||
| 2aade7eef9 | |||
| 71988d8833 | |||
| dd1c7acde1 | |||
| b2d307b308 | |||
| 4f57ac3d9e | |||
| 3d0493e0dd | |||
| 4d35b29526 | |||
| e342fa1d80 | |||
| 8eb1bd98cc | |||
| 644c0d2e28 | |||
| e51357efa7 | |||
| 379a560fbc | |||
| a4cd365c83 | |||
| 3358221da9 | |||
| f1e0ac166e | |||
| 3fab8ea031 | |||
| de4aead219 | |||
| ef2c158727 | |||
| 9ecb3c7269 | |||
| 1936a142b1 | |||
| a9594ccec2 | |||
| 23420762ca | |||
| 04ccdc73ca | |||
| 2e301cd0fc | |||
| d1bcba6a13 | |||
| 6729b60806 | |||
| 7be9a6a41d | |||
| 25a7c967bb | |||
| 713f03284b | |||
| 08bdd515a9 | |||
| eec0ca44c0 | |||
| 9f35d752c2 | |||
| 22f9693957 | |||
| e022aa5ef1 | |||
| 4411c9d17d | |||
| b4f7e7ad8f | |||
| d7ecd6d865 | |||
| a6fb1af6f9 | |||
| d17b038388 | |||
| fff8041faa | |||
| 20ae03cc5e | |||
| ebaa10a79b | |||
| b7e0249757 | |||
| 67540c1808 | |||
| a888969c5d | |||
| 6bd3778ad9 | |||
| 0007343353 | |||
| e6da82c76c | |||
| d8962ff3cc | |||
| 7958e40494 | |||
| 00f1a40e2a | |||
| e38dd4d029 | |||
| 656a21a6dd | |||
| bdc7e58263 | |||
| d47ab3715d | |||
| 20a9388579 | |||
| ef3a682724 | |||
| 4954b51176 | |||
| 01e2422444 | |||
| 7a00e78145 | |||
| e2657ce0a8 | |||
| 76f4b707a6 | |||
| 01d82c16c9 | |||
| 8afd3138f4 | |||
| 3bbc71065a | |||
| 53ba8cb014 | |||
| 829d1a59f7 | |||
| 8ca3576c3e | |||
| a79c09b45d | |||
| f2a198ddaf | |||
| 72fc510167 | |||
| 552c086d3a | |||
| 603421ea87 | |||
| 9e0a43a75f | |||
| 60378db79d | |||
| 7b583f761b | |||
| 50b0866520 | |||
| 01b07a6fa2 | |||
| 3b5b026d43 | |||
| 8b00dcd56e | |||
| 294e38ed31 | |||
| 4bf05f109e | |||
| 6917b19ae8 | |||
| b3749b2a16 | |||
| 314f2a58b5 | |||
| 32066bbf99 | |||
| 6a71f41a19 | |||
| 3eadec9b11 | |||
| ea7feea226 | |||
| 05c69c034e | |||
| a82a8abf65 | |||
| 2fd421e637 | |||
| 6e2efbe544 | |||
| a43c71d94e | |||
| 12fcb9fed7 | |||
| f24a95ab32 | |||
| c03cd63532 | |||
| 1b712424d8 | |||
| 51f7ef9864 | |||
| 040049236d | |||
| 2db5eafabf | |||
| c843b025fc | |||
| 53b4eb03e5 | |||
| e242427228 | |||
| ff60cc4f65 | |||
| e45b67298a | |||
| 579b76dc0e | |||
| b0ae9c7042 | |||
| 11812253e6 | |||
| 399725ed06 | |||
| 574538e7bb | |||
| 45f2d6f4eb | |||
| ff4f823a27 | |||
| c6aa99792f | |||
| 16942a2e63 | |||
| dd003aa00d | |||
| ea94efb65f | |||
| fa3325580c |
@ -1,5 +1,5 @@
|
|||||||
class BaseDialog {
|
class BaseDialog {
|
||||||
constructor(container, options = {}) {
|
constructor(container, options = {}, only = true) {
|
||||||
this.container = container
|
this.container = container
|
||||||
this.options = { ...options }
|
this.options = { ...options }
|
||||||
this.options.ismove = true
|
this.options.ismove = true
|
||||||
@ -9,10 +9,13 @@ class BaseDialog {
|
|||||||
this.closeCallBack = options.closeCallBack
|
this.closeCallBack = options.closeCallBack
|
||||||
this._element = {}
|
this._element = {}
|
||||||
this._element_style = undefined
|
this._element_style = undefined
|
||||||
|
this.only = only
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
if (this.only) {
|
||||||
this.closeAll()
|
this.closeAll()
|
||||||
|
}
|
||||||
DialogAll.push(this)
|
DialogAll.push(this)
|
||||||
this.isDestroy = false
|
this.isDestroy = false
|
||||||
// body
|
// body
|
||||||
@ -48,6 +51,15 @@ class BaseDialog {
|
|||||||
<button class="close">关闭</button>
|
<button class="close">关闭</button>
|
||||||
`
|
`
|
||||||
this._element.body.appendChild(this._element.foot)
|
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];
|
let closeBtnsBox = this._element.body.getElementsByClassName('close-box')[0];
|
||||||
|
|||||||
@ -59,12 +59,17 @@ export default class DrawAttackArrow extends Draw {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
into = '3D'
|
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) {
|
if (!this.entityHasCreated) {
|
||||||
let polyline_id = DrawAttackArrow.create_arrow_polygon(this)
|
let polyline_id = DrawAttackArrow.create_arrow_polygon(this)
|
||||||
this.points_ids.push(polyline_id)
|
this.points_ids.push(polyline_id)
|
||||||
}
|
}
|
||||||
this.points_ids.push(this.create_point(cartesian))
|
this.points_ids.push(this.create_point(cartesian))
|
||||||
cache_positions.push(this.cartesian3Towgs84(cartesian, this.viewer))
|
cache_positions.push(pos84)
|
||||||
isMove = false
|
isMove = false
|
||||||
})
|
})
|
||||||
this.event.mouse_right((movement, cartesian) => {
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export default class DrawCircle extends Draw {
|
|||||||
if (clickNum === 2) {
|
if (clickNum === 2) {
|
||||||
radius_points = cache_points.concat(cartesian)
|
radius_points = cache_points.concat(cartesian)
|
||||||
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
radius = this.computeDistance([center, endpoint])
|
radius = this.computeDistance2([center, endpoint])
|
||||||
positions = this.createCircle(center, radius)
|
positions = this.createCircle(center, radius)
|
||||||
this.end()
|
this.end()
|
||||||
cb(null, { center, radius: Number(radius) })
|
cb(null, { center, radius: Number(radius) })
|
||||||
@ -74,7 +74,7 @@ export default class DrawCircle extends Draw {
|
|||||||
if (clickNum) {
|
if (clickNum) {
|
||||||
radius_points = cache_points.concat(cartesian)
|
radius_points = cache_points.concat(cartesian)
|
||||||
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
radius = this.computeDistance([center, endpoint])
|
radius = this.computeDistance2([center, endpoint])
|
||||||
positions = this.createCircle(center, radius)
|
positions = this.createCircle(center, radius)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ export default class DrawCircle extends Draw {
|
|||||||
if (clickNum === 2) {
|
if (clickNum === 2) {
|
||||||
radius_points = cache_points.concat(cartesian)
|
radius_points = cache_points.concat(cartesian)
|
||||||
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
radius = this.computeDistance([center, endpoint])
|
radius = this.computeDistance2([center, endpoint])
|
||||||
positions = this.createCircle(center, radius)
|
positions = this.createCircle(center, radius)
|
||||||
this.end()
|
this.end()
|
||||||
cb(null, { center, radius: Number(radius) })
|
cb(null, { center, radius: Number(radius) })
|
||||||
@ -136,7 +136,7 @@ export default class DrawCircle extends Draw {
|
|||||||
if (clickNum === 2) {
|
if (clickNum === 2) {
|
||||||
radius_points = cache_points.concat(cartesian)
|
radius_points = cache_points.concat(cartesian)
|
||||||
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
radius = this.computeDistance([center, endpoint])
|
radius = this.computeDistance2([center, endpoint])
|
||||||
positions = this.createCircle(center, radius)
|
positions = this.createCircle(center, radius)
|
||||||
this.end()
|
this.end()
|
||||||
cb(null, { center, radius: Number(radius) })
|
cb(null, { center, radius: Number(radius) })
|
||||||
@ -161,7 +161,7 @@ export default class DrawCircle extends Draw {
|
|||||||
if (clickNum) {
|
if (clickNum) {
|
||||||
radius_points = cache_points.concat(cartesian)
|
radius_points = cache_points.concat(cartesian)
|
||||||
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
radius = this.computeDistance([center, endpoint])
|
radius = this.computeDistance2([center, endpoint])
|
||||||
positions = this.createCircle(center, radius)
|
positions = this.createCircle(center, radius)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ export default class DrawCircle extends Draw {
|
|||||||
if (clickNum === 2) {
|
if (clickNum === 2) {
|
||||||
radius_points = cache_points.concat(cartesian)
|
radius_points = cache_points.concat(cartesian)
|
||||||
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
radius = this.computeDistance([center, endpoint])
|
radius = this.computeDistance2([center, endpoint])
|
||||||
positions = this.createCircle(center, radius)
|
positions = this.createCircle(center, radius)
|
||||||
this.end()
|
this.end()
|
||||||
cb(null, { center, radius: Number(radius) })
|
cb(null, { center, radius: Number(radius) })
|
||||||
@ -227,7 +227,7 @@ export default class DrawCircle extends Draw {
|
|||||||
return '半径:' + radius + ' 米'
|
return '半径:' + radius + ' 米'
|
||||||
}, false),
|
}, false),
|
||||||
font: '20px Microsoft YaHei',
|
font: '20px Microsoft YaHei',
|
||||||
distanceDisplayCondition: 10000000,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
||||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
|||||||
@ -13,6 +13,7 @@ class DrawPolygon extends Draw {
|
|||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}) {
|
constructor(sdk, options = {}) {
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
|
this.color = options.color || 'rgba(255,0,0,0.5)'
|
||||||
this.polygonHasCreated = false
|
this.polygonHasCreated = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,8 +35,8 @@ class DrawPolygon extends Draw {
|
|||||||
positions: new Cesium.CallbackProperty((e) => {
|
positions: new Cesium.CallbackProperty((e) => {
|
||||||
return that.positions.concat(that.positions[0])
|
return that.positions.concat(that.positions[0])
|
||||||
}),
|
}),
|
||||||
width: 2,
|
width: 3,
|
||||||
material: Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5),
|
material: Cesium.Color.fromCssColorString(that.color).withAlpha(1),
|
||||||
clampToGround: true,
|
clampToGround: true,
|
||||||
zIndex: 99999999
|
zIndex: 99999999
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class DrawSector extends Draw {
|
|||||||
this._sector_id = null; //扇形
|
this._sector_id = null; //扇形
|
||||||
this._positions = []; //活动点
|
this._positions = []; //活动点
|
||||||
this.points_ids = []; //脏数据
|
this.points_ids = []; //脏数据
|
||||||
|
this.radius_points = []
|
||||||
this._entities_sector = []; //脏数据
|
this._entities_sector = []; //脏数据
|
||||||
this._radius = 0; //半径
|
this._radius = 0; //半径
|
||||||
this._startAngle = 0; //起始角度
|
this._startAngle = 0; //起始角度
|
||||||
@ -51,9 +52,13 @@ class DrawSector extends Draw {
|
|||||||
cb(null, { center: this._positions[0], radius: this._radius, startAngle: this._startAngle, endAngle: this._endAngle })
|
cb(null, { center: this._positions[0], radius: this._radius, startAngle: this._startAngle, endAngle: this._endAngle })
|
||||||
}
|
}
|
||||||
if (this._positions.length === 2) {
|
if (this._positions.length === 2) {
|
||||||
let pointA = Cesium.Cartesian3.fromDegrees(this._positions[0].lng, this._positions[0].lat, this._positions[0].alt);
|
this.radius_points.push(cartesian)
|
||||||
let pointB = cartesian;
|
this._radius = this.computeDistance2([this._positions[0], this._positions[1]]);
|
||||||
this._radius = Cesium.Cartesian3.distance(pointA, pointB);
|
}
|
||||||
|
if (this._positions.length === 1) {
|
||||||
|
this.radius_points.push(cartesian)
|
||||||
|
let lineId = this.createRadiusLine();
|
||||||
|
this.points_ids.push(lineId);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.event.mouse_move((movement, cartesian) => {
|
this.event.mouse_move((movement, cartesian) => {
|
||||||
@ -65,6 +70,11 @@ class DrawSector extends Draw {
|
|||||||
movement.endPosition.x,
|
movement.endPosition.x,
|
||||||
movement.endPosition.y
|
movement.endPosition.y
|
||||||
)
|
)
|
||||||
|
if (this._positions.length === 1) {
|
||||||
|
this.radius_points[1] = cartesian
|
||||||
|
let endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
|
this._radius = this.computeDistance2([this._positions[0], endpoint]);
|
||||||
|
};
|
||||||
if (this._positions.length < 2) return;
|
if (this._positions.length < 2) return;
|
||||||
if (this._positions.length == 2) {
|
if (this._positions.length == 2) {
|
||||||
this._positions.push(this.cartesian3Towgs84(cartesian, this.viewer));
|
this._positions.push(this.cartesian3Towgs84(cartesian, this.viewer));
|
||||||
@ -108,9 +118,8 @@ class DrawSector extends Draw {
|
|||||||
cb(null, { center: this._positions[0], radius: this._radius, startAngle: this._startAngle, endAngle: this._endAngle })
|
cb(null, { center: this._positions[0], radius: this._radius, startAngle: this._startAngle, endAngle: this._endAngle })
|
||||||
}
|
}
|
||||||
if (this._positions.length === 2) {
|
if (this._positions.length === 2) {
|
||||||
let pointA = Cesium.Cartesian3.fromDegrees(this._positions[0].lng, this._positions[0].lat, this._positions[0].alt);
|
let endpoint = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
let pointB = cartesian;
|
this._radius = this.computeDistance2([this._positions[0], endpoint]);
|
||||||
this._radius = Cesium.Cartesian3.distance(pointA, pointB);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.event2D.mouse_move((movement, cartesian) => {
|
this.event2D.mouse_move((movement, cartesian) => {
|
||||||
@ -198,6 +207,49 @@ class DrawSector extends Draw {
|
|||||||
that._entities_sector.push(arrowEntity);
|
that._entities_sector.push(arrowEntity);
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
//创建半径线
|
||||||
|
createRadiusLine(viewer = this.viewer) {
|
||||||
|
let that = this;
|
||||||
|
let id = that.randomString()
|
||||||
|
let arrowEntity = viewer.entities.add({
|
||||||
|
id: id,
|
||||||
|
position: new Cesium.CallbackProperty((e) => {
|
||||||
|
let center = that._positions[0]
|
||||||
|
|
||||||
|
let endpoint = that.radius_points[1] ? that.cartesian3Towgs84(that.radius_points[1], that.viewer) : that._positions[0]
|
||||||
|
let c = that.computeMidpoint(center, endpoint)
|
||||||
|
return Cesium.Cartesian3.fromDegrees(c.lng, c.lat, endpoint.alt)
|
||||||
|
}, false),
|
||||||
|
polyline: {
|
||||||
|
positions: new Cesium.CallbackProperty((e) => {
|
||||||
|
return that.radius_points
|
||||||
|
}, false),
|
||||||
|
width: 2,
|
||||||
|
material:
|
||||||
|
Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5),
|
||||||
|
clampToGround: true,
|
||||||
|
zIndex: 999999999
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
text: new Cesium.CallbackProperty((e) => {
|
||||||
|
if (this._radius > 1000) {
|
||||||
|
return '半径:' + (this._radius / 1000).toFixed(2) + ' 公里'
|
||||||
|
}
|
||||||
|
return '半径:' + this._radius + ' 米'
|
||||||
|
}, false),
|
||||||
|
font: '20px Microsoft YaHei',
|
||||||
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
|
scale: 1,
|
||||||
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
||||||
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
fillColor: Cesium.Color.fromCssColorString('#f5ce0a'),
|
||||||
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
that._entities_sector.push(arrowEntity);
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
cartesianToLatlng(cartesian) {
|
cartesianToLatlng(cartesian) {
|
||||||
let latlng = this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
|
let latlng = this.viewer.scene.globe.ellipsoid.cartesianToCartographic(cartesian);
|
||||||
|
|||||||
317
src/Draw/drawThreeRect.js
Normal file
317
src/Draw/drawThreeRect.js
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
import MouseTip from '../MouseTip'
|
||||||
|
import MouseEvent from '../Event'
|
||||||
|
import Draw from './draw'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Draw*/
|
||||||
|
class DrawThreeRect extends Draw {
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param [options] {object} 三点矩形属性
|
||||||
|
* @param [options.color=rgba(185,14,14,0.58)] {object} 线属性
|
||||||
|
|
||||||
|
* */
|
||||||
|
constructor(sdk, options = {}) {
|
||||||
|
super(sdk, options)
|
||||||
|
this.polygonHasCreated = false
|
||||||
|
this.rectObject = []
|
||||||
|
}
|
||||||
|
|
||||||
|
static create_polygon(that, viewer = that.viewer) {
|
||||||
|
that.polygonHasCreated = true
|
||||||
|
let id = that.randomString()
|
||||||
|
viewer.entities.add(
|
||||||
|
new Cesium.Entity({
|
||||||
|
id: id,
|
||||||
|
polygon: {
|
||||||
|
classificationType: Cesium.ClassificationType.BOTH,
|
||||||
|
hierarchy: new Cesium.CallbackProperty((e) => {
|
||||||
|
return new Cesium.PolygonHierarchy(that.positions)
|
||||||
|
}),
|
||||||
|
material: Cesium.Color.fromCssColorString(that.color),
|
||||||
|
zIndex: 99999999
|
||||||
|
},
|
||||||
|
polyline: {
|
||||||
|
positions: new Cesium.CallbackProperty((e) => {
|
||||||
|
return that.positions.concat(that.positions[0])
|
||||||
|
}),
|
||||||
|
width: 2,
|
||||||
|
material: Cesium.Color.fromCssColorString('#c1c505').withAlpha(0.5),
|
||||||
|
clampToGround: true,
|
||||||
|
zIndex: 99999999
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
computedLastPoint(arr) {
|
||||||
|
const start = arr[0];
|
||||||
|
const end = arr[1];
|
||||||
|
// 计算点到线的距离
|
||||||
|
const directionVector = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
|
||||||
|
const pointToStart = Cesium.Cartesian3.subtract(arr[2], start, new Cesium.Cartesian3());
|
||||||
|
const projectionLength = Cesium.Cartesian3.dot(pointToStart, directionVector) / Cesium.Cartesian3.magnitudeSquared(directionVector);
|
||||||
|
const projectionVector = Cesium.Cartesian3.multiplyByScalar(directionVector, projectionLength, new Cesium.Cartesian3());
|
||||||
|
const projectionPoint = Cesium.Cartesian3.add(start, projectionVector, new Cesium.Cartesian3());
|
||||||
|
const distance = Cesium.Cartesian3.distance(arr[2], projectionPoint)
|
||||||
|
|
||||||
|
const perp = Cesium.Cartesian3.subtract(arr[2], projectionPoint, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perp, perp);
|
||||||
|
// 生成偏移向量
|
||||||
|
const offset = Cesium.Cartesian3.multiplyByScalar(perp, distance, new Cesium.Cartesian3());
|
||||||
|
let threePoint = Cesium.Cartesian3.add(end, offset, new Cesium.Cartesian3())
|
||||||
|
let lastPoint = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3())
|
||||||
|
return [{ ...threePoint }, { ...lastPoint }]
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @desc 开始动态绘制面
|
||||||
|
* @method start
|
||||||
|
* @param cb {function} 回调函数
|
||||||
|
* @memberOf DrawPolygon
|
||||||
|
* @example draw.start((err,positions)=>{
|
||||||
|
*
|
||||||
|
* })
|
||||||
|
* */
|
||||||
|
start(cb) {
|
||||||
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
|
cb('上一次测量未结束')
|
||||||
|
} else {
|
||||||
|
this.polygonHasCreated = false
|
||||||
|
super.start()
|
||||||
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
|
let into
|
||||||
|
this.tip = new MouseTip('左键确定,右键结束;CTRL+右键撤销', this.sdk)
|
||||||
|
this.event = new MouseEvent(this.sdk)
|
||||||
|
let cnt = 0
|
||||||
|
this.positions = []
|
||||||
|
this.positionsLine = []
|
||||||
|
this.points_ids = [] //存放左键点击时临时添加的point的id
|
||||||
|
let cache_positions = []
|
||||||
|
let cache_84_position = []
|
||||||
|
this.event.mouse_left((movement, cartesian) => {
|
||||||
|
if (into === '2D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
into = '3D'
|
||||||
|
cnt++
|
||||||
|
this.positions = cache_positions.concat({ ...cartesian })
|
||||||
|
this.tip.setPosition(
|
||||||
|
cartesian,
|
||||||
|
movement.position.x,
|
||||||
|
movement.position.y
|
||||||
|
)
|
||||||
|
if (!this.polygonHasCreated) {
|
||||||
|
let polyline_id = DrawThreeRect.create_polygon(this)
|
||||||
|
this.points_ids.push(polyline_id)
|
||||||
|
}
|
||||||
|
cache_positions.push(cartesian)
|
||||||
|
cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer))
|
||||||
|
this.points_ids.push(this.create_point(cartesian))
|
||||||
|
if (cnt == 3) {
|
||||||
|
this.end()
|
||||||
|
cb(null, this.rectObject)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
|
if (into === '2D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// let positions = []
|
||||||
|
// console.log(cache_positions)
|
||||||
|
// cache_positions.forEach((item) => {
|
||||||
|
// let p = this.cartesian3Towgs84(item)
|
||||||
|
// console.log(item)
|
||||||
|
// positions.push(p)
|
||||||
|
// })
|
||||||
|
this.end()
|
||||||
|
cb('取消', '')
|
||||||
|
})
|
||||||
|
this.event.mouse_move((movement, cartesian) => {
|
||||||
|
if (into === '2D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// this.positions = cache_positions.concat({ ...cartesian })
|
||||||
|
this.tip.setPosition(
|
||||||
|
cartesian,
|
||||||
|
movement.endPosition.x,
|
||||||
|
movement.endPosition.y
|
||||||
|
)
|
||||||
|
|
||||||
|
if (cnt == 2) {
|
||||||
|
let arr = JSON.parse(JSON.stringify(cache_positions))
|
||||||
|
let arr1 = arr.concat({ ...cartesian })
|
||||||
|
let pointArr = this.computedLastPoint(arr1)
|
||||||
|
arr = arr.concat(pointArr)
|
||||||
|
this.positions = arr
|
||||||
|
let arr_84 = arr.map(item => {
|
||||||
|
return this.cartesian3Towgs84(item, this.viewer)
|
||||||
|
})
|
||||||
|
this.rectObject = arr_84
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||||
|
if (into === '2D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.points_ids.length > 1) {
|
||||||
|
this.remove_entity(this.points_ids.pop()) //移除point
|
||||||
|
cache_positions.pop()
|
||||||
|
cache_84_position.pop()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.event.gesture_pinck_start_keyboard_ctrl(() => {
|
||||||
|
if (into === '2D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.points_ids.length > 1) {
|
||||||
|
this.remove_entity(this.points_ids.pop()) //移除point
|
||||||
|
cache_positions.pop()
|
||||||
|
cache_84_position.pop()
|
||||||
|
this.positions = cache_positions.concat(cartesian)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||||
|
if (into === '2D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let startTime = new Date()
|
||||||
|
this.event.gesture_pinck_end(() => {
|
||||||
|
let endTime = new Date()
|
||||||
|
if (endTime - startTime >= 500) {
|
||||||
|
cb(null, cache_84_position)
|
||||||
|
this.end()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.tip.setPosition(
|
||||||
|
cartesian,
|
||||||
|
(movement.position1.x + movement.position2.x) / 2,
|
||||||
|
(movement.position1.y + movement.position2.y) / 2
|
||||||
|
)
|
||||||
|
if (!this.polygonHasCreated) {
|
||||||
|
let polyline_id = DrawThreeRect.create_polygon(this)
|
||||||
|
this.points_ids.push(polyline_id)
|
||||||
|
}
|
||||||
|
cache_positions.push(cartesian)
|
||||||
|
cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer))
|
||||||
|
this.points_ids.push(this.create_point(cartesian))
|
||||||
|
this.positions = cache_positions.concat(cartesian)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!this._is2D && this._sdk2D) {
|
||||||
|
this.event2D = new MouseEvent(this._sdk2D)
|
||||||
|
this.event2D.mouse_left((movement, cartesian) => {
|
||||||
|
if (into === '3D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
into = '2D'
|
||||||
|
cnt++
|
||||||
|
this.positions = cache_positions.concat({ ...cartesian })
|
||||||
|
this.tip.setPosition(
|
||||||
|
cartesian,
|
||||||
|
movement.position.x + this.viewer.canvas.width,
|
||||||
|
movement.position.y
|
||||||
|
)
|
||||||
|
if (!this.polygonHasCreated) {
|
||||||
|
let polyline_id = DrawThreeRect.create_polygon(this, this._sdk2D.viewer)
|
||||||
|
this.points_ids.push(polyline_id)
|
||||||
|
}
|
||||||
|
cache_positions.push(cartesian)
|
||||||
|
cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer))
|
||||||
|
this.points_ids.push(this.create_point(cartesian, this._sdk2D.viewer))
|
||||||
|
if (cnt == 3) {
|
||||||
|
this.end()
|
||||||
|
cb(null, this.rectObject)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.event2D.mouse_right((movement, cartesian) => {
|
||||||
|
if (into === '3D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.end()
|
||||||
|
cb('取消', '')
|
||||||
|
})
|
||||||
|
this.event2D.mouse_move((movement, cartesian) => {
|
||||||
|
if (into === '3D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// this.positions = cache_positions.concat({ ...cartesian })
|
||||||
|
this.tip.setPosition(
|
||||||
|
cartesian,
|
||||||
|
movement.endPosition.x + this.viewer.canvas.width,
|
||||||
|
movement.endPosition.y
|
||||||
|
)
|
||||||
|
|
||||||
|
if (cnt == 2) {
|
||||||
|
let arr = JSON.parse(JSON.stringify(cache_positions))
|
||||||
|
let arr1 = arr.concat({ ...cartesian })
|
||||||
|
let pointArr = this.computedLastPoint(arr1)
|
||||||
|
arr = arr.concat(pointArr)
|
||||||
|
this.positions = arr
|
||||||
|
let arr_84 = arr.map(item => {
|
||||||
|
return this.cartesian3Towgs84(item, this.viewer)
|
||||||
|
})
|
||||||
|
this.rectObject = arr_84
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.event2D.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||||
|
if (into === '3D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.points_ids.length > 1) {
|
||||||
|
this.remove_entity(this.points_ids.pop()) //移除point
|
||||||
|
cache_positions.pop()
|
||||||
|
cache_84_position.pop()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.event2D.gesture_pinck_start_keyboard_ctrl(() => {
|
||||||
|
if (into === '3D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.points_ids.length > 1) {
|
||||||
|
this.remove_entity(this.points_ids.pop()) //移除point
|
||||||
|
cache_positions.pop()
|
||||||
|
cache_84_position.pop()
|
||||||
|
this.positions = cache_positions.concat(cartesian)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.event2D.gesture_pinck_start((movement, cartesian) => {
|
||||||
|
if (into === '3D') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let startTime = new Date()
|
||||||
|
this.event2D.gesture_pinck_end(() => {
|
||||||
|
let endTime = new Date()
|
||||||
|
if (endTime - startTime >= 500) {
|
||||||
|
cb(null, cache_84_position)
|
||||||
|
this.end()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.tip.setPosition(
|
||||||
|
cartesian,
|
||||||
|
((movement.position1.x + movement.position2.x) / 2) + this.viewer.canvas.width,
|
||||||
|
(movement.position1.y + movement.position2.y) / 2
|
||||||
|
)
|
||||||
|
if (!this.polygonHasCreated) {
|
||||||
|
let polyline_id = DrawThreeRect.create_polygon(this, this._sdk2D.viewer)
|
||||||
|
this.points_ids.push(polyline_id)
|
||||||
|
}
|
||||||
|
cache_positions.push(cartesian)
|
||||||
|
cache_84_position.push(this.cartesian3Towgs84(cartesian, this.viewer))
|
||||||
|
this.points_ids.push(this.create_point(cartesian, this._sdk2D.viewer))
|
||||||
|
this.positions = cache_positions.concat(cartesian)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DrawThreeRect
|
||||||
109
src/Global/Contour/_element.js
Normal file
109
src/Global/Contour/_element.js
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
function html() {
|
||||||
|
return `
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row" style="align-items: flex-start;">
|
||||||
|
<div class="col" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">等高线</span>
|
||||||
|
<input class="btn-switch show" type="checkbox">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col input-select-unit-box">
|
||||||
|
<span class="label">等高距</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input equal-height-distance" type="number" title="" min="1" max="1000">
|
||||||
|
<span class="unit">m</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box" style="flex: 0 0 60px;">
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box" style="flex: 0 0 157px;">
|
||||||
|
<span class="label">选中线颜色</span>
|
||||||
|
<div class="active-color"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row" style="align-items: flex-start;">
|
||||||
|
<div class="col" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">计曲线</span>
|
||||||
|
<input class="btn-switch index-contour-switch" type="checkbox">
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">计曲线颜色</span>
|
||||||
|
<div class="index-contour-color"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box">
|
||||||
|
<span class="label">计曲线宽度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input index-contour-width" type="number" title="" step="0.1" min="1" max="10">
|
||||||
|
<span class="unit">px</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="align-items: flex-start;">
|
||||||
|
<div class="col" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">首曲线</span>
|
||||||
|
<input class="btn-switch intermediate-contour-switch" type="checkbox">
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">首曲线颜色</span>
|
||||||
|
<div class="intermediate-contour-color"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box">
|
||||||
|
<span class="label">首曲线宽度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input intermediate-contour-width" type="number" step="0.1" title="" min="1" max="10">
|
||||||
|
<span class="unit">px</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="align-items: flex-start;">
|
||||||
|
<div class="col" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">间曲线</span>
|
||||||
|
<input class="btn-switch halfInterval-contour-switch" type="checkbox">
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">间曲线颜色</span>
|
||||||
|
<div class="halfInterval-contour-color"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box">
|
||||||
|
<span class="label">间曲线宽度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input halfInterval-contour-width" type="number" title="" min="1" max="10">
|
||||||
|
<span class="unit">px</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="align-items: flex-start;">
|
||||||
|
<div class="col" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">助曲线</span>
|
||||||
|
<input class="btn-switch supplementary-contour-switch" type="checkbox">
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box" style="flex: 0 0 120px;">
|
||||||
|
<span class="label">助曲线颜色</span>
|
||||||
|
<div class="supplementary-contour-color"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col input-select-unit-box">
|
||||||
|
<span class="label">助曲线宽度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input supplementary-contour-width" type="number" title="" min="1" max="10">
|
||||||
|
<span class="unit">px</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export { html }
|
||||||
@ -3,12 +3,35 @@
|
|||||||
*/
|
*/
|
||||||
import Dialog from "../../Obj/Element/Dialog";
|
import Dialog from "../../Obj/Element/Dialog";
|
||||||
import Tools from "../../Tools";
|
import Tools from "../../Tools";
|
||||||
|
import { flyTo } from '../global'
|
||||||
|
import YJColorPicker from "../../Obj/Element/yj-color-picker";
|
||||||
|
|
||||||
|
import { html } from "./_element";
|
||||||
|
|
||||||
let _DialogObject = null;
|
let _DialogObject = null;
|
||||||
let material = null;
|
let material = null;
|
||||||
let handler = null;
|
let handler = null;
|
||||||
let activeHeightElm = null;
|
let activeHeightElm = null;
|
||||||
let tools
|
let tools
|
||||||
|
let _sdk
|
||||||
|
let secondaryLinesCount = 19
|
||||||
|
let show = false
|
||||||
|
let equalHeightDistance = 10
|
||||||
|
let activeColor = '#ffd000'
|
||||||
|
let indexContourShow = true
|
||||||
|
let indexContourWidth = 2.5
|
||||||
|
let indexContourColor = '#43cf7c'
|
||||||
|
let intermediateContourShow = true
|
||||||
|
let intermediateContourWidth = 1.8
|
||||||
|
let intermediateContourColor = '#ff0000'
|
||||||
|
let halfIntervalContourShow = false
|
||||||
|
let halfIntervalContourWidth = 1.0
|
||||||
|
let halfIntervalContourColor = '#64b6d9'
|
||||||
|
let supplementaryContourShow = false
|
||||||
|
let supplementaryContourWidth = 1.0
|
||||||
|
let supplementaryContourColor = '#d084d1'
|
||||||
|
|
||||||
|
|
||||||
activeHeightElm = document.createElement('div')
|
activeHeightElm = document.createElement('div')
|
||||||
activeHeightElm.className = 'YJ-customize-active-height-elm'
|
activeHeightElm.className = 'YJ-customize-active-height-elm'
|
||||||
activeHeightElm.style.position = 'absolute'
|
activeHeightElm.style.position = 'absolute'
|
||||||
@ -20,7 +43,39 @@ activeHeightElm.style.textAlign = 'center'
|
|||||||
activeHeightElm.style.pointerEvents = 'none'
|
activeHeightElm.style.pointerEvents = 'none'
|
||||||
activeHeightElm.style.color = '#ff0000'
|
activeHeightElm.style.color = '#ff0000'
|
||||||
activeHeightElm.style.display = 'none'
|
activeHeightElm.style.display = 'none'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function accordingToCameraHeight() {
|
||||||
|
if (_sdk) {
|
||||||
|
const camera = _sdk.viewer.camera;
|
||||||
|
const position = camera.positionCartographic;
|
||||||
|
|
||||||
|
// 计算相机高度(相对于椭球面)
|
||||||
|
let cameraHeight = Cesium.Math.toDegrees(position.height);
|
||||||
|
if (cameraHeight < 1000000) {
|
||||||
|
if (!_sdk.viewer.scene.globe.material && show === true) {
|
||||||
|
showContour(_sdk)
|
||||||
|
}
|
||||||
|
// if (material) {
|
||||||
|
// if (cameraHeight > 450000) {
|
||||||
|
// material.uniforms.supplementaryContourShow = false
|
||||||
|
// }
|
||||||
|
// else if (supplementaryContourShow) {
|
||||||
|
// material.uniforms.supplementaryContourShow = true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hideContour(_sdk)
|
||||||
|
}
|
||||||
|
// console.log(cameraHeight)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
async function dialog(sdk) {
|
async function dialog(sdk) {
|
||||||
|
_sdk = sdk
|
||||||
|
|
||||||
if (!sdk || _DialogObject) {
|
if (!sdk || _DialogObject) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -28,13 +83,12 @@ async function dialog(sdk) {
|
|||||||
createMaterial()
|
createMaterial()
|
||||||
}
|
}
|
||||||
if (!tools) {
|
if (!tools) {
|
||||||
tools = new Tools()
|
tools = new Tools(sdk)
|
||||||
}
|
}
|
||||||
|
|
||||||
_DialogObject = await new Dialog(sdk, {}, {
|
_DialogObject = await new Dialog(sdk, {}, {
|
||||||
title: "等高线", left: '180px',
|
title: "全局等高线", left: '180px',
|
||||||
top: '100px',
|
top: '100px',
|
||||||
confirmCallBack: options => { },
|
|
||||||
closeCallBack: () => {
|
closeCallBack: () => {
|
||||||
_DialogObject = null
|
_DialogObject = null
|
||||||
}
|
}
|
||||||
@ -43,63 +97,292 @@ async function dialog(sdk) {
|
|||||||
_DialogObject._element.body.className =
|
_DialogObject._element.body.className =
|
||||||
_DialogObject._element.body.className + ' contour'
|
_DialogObject._element.body.className + ' contour'
|
||||||
let contentElm = document.createElement('div')
|
let contentElm = document.createElement('div')
|
||||||
contentElm.innerHTML = `
|
contentElm.innerHTML = html(this)
|
||||||
<span class="custom-divider"></span>
|
|
||||||
<div class="div-item">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col input-select-unit-box">
|
|
||||||
<span class="label">高差</span>
|
|
||||||
<div class="input-number input-number-unit-1">
|
|
||||||
<input class="input gap" type="number" title="" min="0" max="1000">
|
|
||||||
<span class="unit">m</span>
|
|
||||||
<span class="arrow"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col input-select-unit-box" style="flex: 0 0 120px;">
|
|
||||||
<span class="label">主线颜色</span>
|
|
||||||
<div class="primary-lice-color"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col input-select-unit-box">
|
|
||||||
<span class="label">次线条数</span>
|
|
||||||
<div class="input-number input-number-unit-1">
|
|
||||||
<input class="input gap2" type="number" title="" min="0" max="10">
|
|
||||||
<span class="unit"></span>
|
|
||||||
<span class="arrow"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col input-select-unit-box" style="flex: 0 0 120px;">
|
|
||||||
<span class="label">次线颜色</span>
|
|
||||||
<div class="secondary-lice-color"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row" style="align-items: flex-start;">
|
|
||||||
<div class="col">
|
|
||||||
</div>
|
|
||||||
<div class="col" style="flex: 0 0 120px;">
|
|
||||||
<span class="label">开关</span>
|
|
||||||
<input class="btn-switch" type="checkbox">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span class="custom-divider"></span>
|
|
||||||
`
|
|
||||||
contentElm.innerHTML = `
|
|
||||||
<span class="custom-divider"></span>
|
|
||||||
<div class="div-item">
|
|
||||||
<div class="row" style="align-items: flex-start;">
|
|
||||||
<div class="col" style="flex: 0 0 120px;">
|
|
||||||
<span class="label">开关</span>
|
|
||||||
<input class="btn-switch" type="checkbox">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
_DialogObject.contentAppChild(contentElm)
|
_DialogObject.contentAppChild(contentElm)
|
||||||
|
|
||||||
contentElm.getElementsByClassName('btn-switch')[0].addEventListener('change', (e) => {
|
sdk.viewer.scene.postRender.removeEventListener(accordingToCameraHeight)
|
||||||
|
sdk.viewer.scene.postRender.addEventListener(accordingToCameraHeight)
|
||||||
|
|
||||||
|
// 显示
|
||||||
|
let showBtn = contentElm.getElementsByClassName('show')[0]
|
||||||
|
showBtn.checked = show
|
||||||
|
showBtn.addEventListener('change', (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
|
show = true
|
||||||
|
let height = sdk.viewer.camera.positionCartographic.height
|
||||||
|
if (height > 16360) {
|
||||||
|
let cartographic = sdk.viewer.camera.positionCartographic
|
||||||
|
let options = {
|
||||||
|
position: {
|
||||||
|
lng: Cesium.Math.toDegrees(cartographic.longitude),
|
||||||
|
lat: Cesium.Math.toDegrees(cartographic.latitude),
|
||||||
|
alt: 16360,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
flyTo(sdk, options, 0.5)
|
||||||
|
}
|
||||||
|
showContour(sdk)
|
||||||
|
} else {
|
||||||
|
show = false
|
||||||
|
hideContour(sdk)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 等高距
|
||||||
|
let equalHeightDistanceInput = contentElm.getElementsByClassName('equal-height-distance')[0]
|
||||||
|
equalHeightDistanceInput.value = equalHeightDistance
|
||||||
|
equalHeightDistanceInput.addEventListener('blur', (e) => {
|
||||||
|
let value = initInputValue(e)
|
||||||
|
equalHeightDistance = value
|
||||||
|
equalHeightDistanceInput.value = value
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.spacing = equalHeightDistance * 5
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 选中颜色
|
||||||
|
// let activeColorPicker = new YJColorPicker({
|
||||||
|
// el: contentElm.getElementsByClassName('active-color')[0],
|
||||||
|
// size: "mini",
|
||||||
|
// isLog: false,
|
||||||
|
// alpha: true, //是否开启透明度
|
||||||
|
// disabled: false, //是否禁止打开颜色选择器
|
||||||
|
// predefineColor: true, // 预定义颜色
|
||||||
|
// defaultColor: '#ffffff',
|
||||||
|
// sure: color => {
|
||||||
|
// activeColor = color
|
||||||
|
// if (material) {
|
||||||
|
// material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// clear: () => {
|
||||||
|
// activeColor = 'rgba(255,255,255,1)'
|
||||||
|
// if (material) {
|
||||||
|
// material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
let activeColorPicker = new YJColorPicker({
|
||||||
|
el: contentElm.getElementsByClassName('active-color')[0],
|
||||||
|
size: 'mini',//颜色box类型
|
||||||
|
alpha: true,//是否开启透明度
|
||||||
|
defaultColor: activeColor,
|
||||||
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
|
sure: color => {
|
||||||
|
activeColor = color
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: () => {
|
||||||
|
activeColor = 'rgba(255,255,255,1)'
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.activeColor = Cesium.Color.fromCssColorString(activeColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 计曲线开关
|
||||||
|
let indexContourSwitch = contentElm.getElementsByClassName('index-contour-switch')[0]
|
||||||
|
indexContourSwitch.checked = indexContourShow
|
||||||
|
indexContourSwitch.addEventListener('change', (e) => {
|
||||||
|
indexContourShow = e.target.checked
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.indexContourShow = indexContourShow
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 计曲线颜色
|
||||||
|
let indexContourColorPicker = new YJColorPicker({
|
||||||
|
el: contentElm.getElementsByClassName('index-contour-color')[0],
|
||||||
|
size: 'mini',//颜色box类型
|
||||||
|
alpha: true,//是否开启透明度
|
||||||
|
defaultColor: indexContourColor,
|
||||||
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
|
sure: color => {
|
||||||
|
indexContourColor = color
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: () => {
|
||||||
|
indexContourColor = 'rgba(255,255,255,1)'
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.indexContourColor = Cesium.Color.fromCssColorString(indexContourColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 计曲线宽度
|
||||||
|
let indexContourWidthInput = contentElm.getElementsByClassName('index-contour-width')[0]
|
||||||
|
indexContourWidthInput.value = indexContourWidth
|
||||||
|
indexContourWidthInput.addEventListener('blur', (e) => {
|
||||||
|
let value = initInputValue(e)
|
||||||
|
indexContourWidth = value
|
||||||
|
indexContourWidthInput.value = value
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.indexContourWidth = indexContourWidth
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 首曲线开关
|
||||||
|
let intermediateContourSwitch = contentElm.getElementsByClassName('intermediate-contour-switch')[0]
|
||||||
|
intermediateContourSwitch.checked = intermediateContourShow
|
||||||
|
intermediateContourSwitch.addEventListener('change', (e) => {
|
||||||
|
intermediateContourShow = e.target.checked
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.intermediateContourShow = intermediateContourShow
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 首曲线颜色
|
||||||
|
let intermediateContourColorPicker = new YJColorPicker({
|
||||||
|
el: contentElm.getElementsByClassName('intermediate-contour-color')[0],
|
||||||
|
size: 'mini',//颜色box类型
|
||||||
|
alpha: true,//是否开启透明度
|
||||||
|
defaultColor: intermediateContourColor,
|
||||||
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
|
sure: color => {
|
||||||
|
intermediateContourColor = color
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: () => {
|
||||||
|
intermediateContourColor = 'rgba(255,255,255,1)'
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.intermediateContourColor = Cesium.Color.fromCssColorString(intermediateContourColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 首曲线宽度
|
||||||
|
let intermediateContourWidthInput = contentElm.getElementsByClassName('intermediate-contour-width')[0]
|
||||||
|
intermediateContourWidthInput.value = intermediateContourWidth
|
||||||
|
intermediateContourWidthInput.addEventListener('blur', (e) => {
|
||||||
|
let value = initInputValue(e)
|
||||||
|
intermediateContourWidth = value
|
||||||
|
intermediateContourWidthInput.value = value
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.intermediateContourWidth = intermediateContourWidth
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 间曲线开关
|
||||||
|
let halfIntervalContourSwitch = contentElm.getElementsByClassName('halfInterval-contour-switch')[0]
|
||||||
|
halfIntervalContourSwitch.checked = halfIntervalContourShow
|
||||||
|
halfIntervalContourSwitch.addEventListener('change', (e) => {
|
||||||
|
halfIntervalContourShow = e.target.checked
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.halfIntervalContourShow = halfIntervalContourShow
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 间曲线颜色
|
||||||
|
let halfIntervalContourColorPicker = new YJColorPicker({
|
||||||
|
el: contentElm.getElementsByClassName('halfInterval-contour-color')[0],
|
||||||
|
size: 'mini',//颜色box类型
|
||||||
|
alpha: true,//是否开启透明度
|
||||||
|
defaultColor: halfIntervalContourColor,
|
||||||
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
|
sure: color => {
|
||||||
|
halfIntervalContourColor = color
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: () => {
|
||||||
|
halfIntervalContourColor = 'rgba(255,255,255,1)'
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.halfIntervalContourColor = Cesium.Color.fromCssColorString(halfIntervalContourColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 间曲线宽度
|
||||||
|
let halfIntervalContourWidthInput = contentElm.getElementsByClassName('halfInterval-contour-width')[0]
|
||||||
|
halfIntervalContourWidthInput.value = halfIntervalContourWidth
|
||||||
|
halfIntervalContourWidthInput.addEventListener('blur', (e) => {
|
||||||
|
let value = initInputValue(e)
|
||||||
|
halfIntervalContourWidth = value
|
||||||
|
halfIntervalContourWidthInput.value = value
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.halfIntervalContourWidth = halfIntervalContourWidth
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 助曲线开关
|
||||||
|
let supplementaryContourSwitch = contentElm.getElementsByClassName('supplementary-contour-switch')[0]
|
||||||
|
supplementaryContourSwitch.checked = supplementaryContourShow
|
||||||
|
supplementaryContourSwitch.addEventListener('change', (e) => {
|
||||||
|
supplementaryContourShow = e.target.checked
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.supplementaryContourShow = supplementaryContourShow
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 助曲线颜色
|
||||||
|
let supplementaryContourColorPicker = new YJColorPicker({
|
||||||
|
el: contentElm.getElementsByClassName('supplementary-contour-color')[0],
|
||||||
|
size: 'mini',//颜色box类型
|
||||||
|
alpha: true,//是否开启透明度
|
||||||
|
defaultColor: supplementaryContourColor,
|
||||||
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
|
sure: color => {
|
||||||
|
supplementaryContourColor = color
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: () => {
|
||||||
|
supplementaryContourColor = 'rgba(255,255,255,1)'
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.supplementaryContourColor = Cesium.Color.fromCssColorString(supplementaryContourColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 助曲线宽度
|
||||||
|
let supplementaryContourWidthInput = contentElm.getElementsByClassName('supplementary-contour-width')[0]
|
||||||
|
supplementaryContourWidthInput.value = supplementaryContourWidth
|
||||||
|
supplementaryContourWidthInput.addEventListener('blur', (e) => {
|
||||||
|
let value = initInputValue(e)
|
||||||
|
supplementaryContourWidth = value
|
||||||
|
supplementaryContourWidthInput.value = value
|
||||||
|
if (material) {
|
||||||
|
material.uniforms.supplementaryContourWidth = supplementaryContourWidth
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function initInputValue(e) {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
|
||||||
|
value = Number(value)
|
||||||
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function showContour(sdk) {
|
||||||
|
const camera = sdk.viewer.camera;
|
||||||
|
const position = camera.positionCartographic;
|
||||||
|
// 计算相机高度(相对于椭球面)
|
||||||
|
let cameraHeight = Cesium.Math.toDegrees(position.height);
|
||||||
|
if (cameraHeight > 1000000) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (handler) {
|
if (handler) {
|
||||||
handler.destroy()
|
handler.destroy()
|
||||||
}
|
}
|
||||||
@ -123,11 +406,16 @@ async function dialog(sdk) {
|
|||||||
activeHeightElm.style.left = movement.endPosition.x - 50 + left + 'px'
|
activeHeightElm.style.left = movement.endPosition.x - 50 + left + 'px'
|
||||||
activeHeightElm.style.top = movement.endPosition.y - 40 + top + 'px'
|
activeHeightElm.style.top = movement.endPosition.y - 40 + top + 'px'
|
||||||
activeHeightElm.style.display = 'block'
|
activeHeightElm.style.display = 'block'
|
||||||
|
// let pos = sdk.viewer.scene.clampToHeight(cartesian)
|
||||||
let pos84 = tools.cartesian3Towgs84(cartesian, sdk.viewer)
|
let pos84 = tools.cartesian3Towgs84(cartesian, sdk.viewer)
|
||||||
|
// pos84.alt = height
|
||||||
let mainContourHeight = Math.floor(pos84.alt / material.uniforms.spacing) * material.uniforms.spacing
|
let mainContourHeight = Math.floor(pos84.alt / material.uniforms.spacing) * material.uniforms.spacing
|
||||||
let gap = pos84.alt - mainContourHeight
|
let gap = pos84.alt - mainContourHeight
|
||||||
let gap2 = material.uniforms.spacing / (material.uniforms.secondaryLinesCount + 1)
|
let gap2 = material.uniforms.spacing / (material.uniforms.secondaryLinesCount + 1)
|
||||||
let activeHeight = Math.floor(gap / gap2) * gap2 + mainContourHeight
|
let activeHeight = Math.floor(gap / gap2) * gap2 + mainContourHeight
|
||||||
|
if (pos84.alt < 0) {
|
||||||
|
pos84.alt = 0
|
||||||
|
}
|
||||||
if ((pos84.alt - activeHeight) > gap2 / 2) {
|
if ((pos84.alt - activeHeight) > gap2 / 2) {
|
||||||
activeHeight = activeHeight + gap2
|
activeHeight = activeHeight + gap2
|
||||||
}
|
}
|
||||||
@ -140,7 +428,8 @@ async function dialog(sdk) {
|
|||||||
}
|
}
|
||||||
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
|
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
|
||||||
sdk.viewer.scene.globe.material = material;
|
sdk.viewer.scene.globe.material = material;
|
||||||
} else {
|
}
|
||||||
|
function hideContour(sdk) {
|
||||||
if (handler) {
|
if (handler) {
|
||||||
handler.destroy()
|
handler.destroy()
|
||||||
handler = null
|
handler = null
|
||||||
@ -151,17 +440,31 @@ async function dialog(sdk) {
|
|||||||
}
|
}
|
||||||
sdk.viewer.scene.globe.material = null;
|
sdk.viewer.scene.globe.material = null;
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function createMaterial() {
|
function createMaterial() {
|
||||||
Cesium.Material._materialCache._materials.ElevationContour.fabric.source = `
|
Cesium.Material._materialCache._materials.ElevationContour.fabric.source = `
|
||||||
uniform vec4 color;
|
uniform vec4 activeColor; // 选中颜色
|
||||||
uniform vec4 secondaryLinesColor;
|
uniform float spacing; // 等高距
|
||||||
uniform float spacing;
|
|
||||||
uniform float width;
|
// 计曲线
|
||||||
uniform float secondaryLinesWidth;
|
uniform bool indexContourShow;
|
||||||
|
uniform float indexContourWidth;
|
||||||
|
uniform vec4 indexContourColor;
|
||||||
|
// 首曲线
|
||||||
|
uniform bool intermediateContourShow;
|
||||||
|
uniform float intermediateContourWidth;
|
||||||
|
uniform vec4 intermediateContourColor;
|
||||||
|
// 间曲线
|
||||||
|
uniform bool halfIntervalContourShow;
|
||||||
|
uniform float halfIntervalContourWidth;
|
||||||
|
uniform vec4 halfIntervalContourColor;
|
||||||
|
// 助曲线
|
||||||
|
uniform bool supplementaryContourShow;
|
||||||
|
uniform float supplementaryContourWidth;
|
||||||
|
uniform vec4 supplementaryContourColor;
|
||||||
|
|
||||||
uniform float mouseHeight;
|
uniform float mouseHeight;
|
||||||
|
|
||||||
uniform float secondaryLinesCount; // 0=无次线, 1=1条次线, 2=2条次线...
|
uniform float secondaryLinesCount; // 0=无次线, 1=1条次线, 2=2条次线...
|
||||||
|
|
||||||
czm_material czm_getMaterial(czm_materialInput materialInput)
|
czm_material czm_getMaterial(czm_materialInput materialInput)
|
||||||
@ -175,18 +478,32 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|||||||
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
|
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
|
||||||
float dxc = abs(dFdx(materialInput.height));
|
float dxc = abs(dFdx(materialInput.height));
|
||||||
float dyc = abs(dFdy(materialInput.height));
|
float dyc = abs(dFdy(materialInput.height));
|
||||||
float dFMain = max(dxc, dyc) * czm_pixelRatio * width;
|
float dFMain = max(dxc, dyc) * czm_pixelRatio * indexContourWidth;
|
||||||
#else
|
#else
|
||||||
float dFMain = czm_pixelRatio * width;
|
float dFMain = czm_pixelRatio * indexContourWidth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isMainContour = distanceToMainContour < dFMain;
|
bool isMainContour = distanceToMainContour < dFMain;
|
||||||
bool isSecondaryContour = false;
|
bool isSecondaryContour = false;
|
||||||
float dFSecondary = 0.0;
|
float dFSecondary = 0.0;
|
||||||
float secondarySpacing = 0.0;
|
float secondarySpacing = 0.0;
|
||||||
|
bool isHalfInterval = false;
|
||||||
|
bool isIntermediate= false;
|
||||||
|
|
||||||
|
// 计算当前高度所属的等高线高度
|
||||||
|
float mainContourHeight = floor(materialInput.height / spacing) * spacing;
|
||||||
|
float secondaryContourHeight = floor(materialInput.height / spacing * (secondaryLinesCount + 1.0)) * spacing / (secondaryLinesCount + 1.0);
|
||||||
|
|
||||||
|
// 计算次线在两条主等高线之间的相对位置
|
||||||
|
float relativeHeight = materialInput.height - mainContourHeight;
|
||||||
|
float normalizedPosition = relativeHeight / spacing;
|
||||||
|
|
||||||
|
// 计算次线索引(从主等高线开始计数)
|
||||||
|
float lineIndex = floor(normalizedPosition * (secondaryLinesCount + 1.0));
|
||||||
|
|
||||||
// 只有当存在次线时才计算次线
|
// 只有当存在次线时才计算次线
|
||||||
if(secondaryLinesCount > 0.0) {
|
if(secondaryLinesCount > 0.0) {
|
||||||
|
float secondaryLinesWidth = supplementaryContourWidth;
|
||||||
secondarySpacing = spacing / (secondaryLinesCount + 1.0);
|
secondarySpacing = spacing / (secondaryLinesCount + 1.0);
|
||||||
float distanceToSecondaryContour = mod(materialInput.height, secondarySpacing);
|
float distanceToSecondaryContour = mod(materialInput.height, secondarySpacing);
|
||||||
|
|
||||||
@ -194,6 +511,28 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|||||||
float minDistanceToMain = min(distanceToMainContour, spacing - distanceToMainContour);
|
float minDistanceToMain = min(distanceToMainContour, spacing - distanceToMainContour);
|
||||||
bool notCloseToMain = minDistanceToMain > dFMain * 2.0; // 2倍线宽缓冲
|
bool notCloseToMain = minDistanceToMain > dFMain * 2.0; // 2倍线宽缓冲
|
||||||
|
|
||||||
|
|
||||||
|
if (lineIndex > 0.0 && lineIndex < secondaryLinesCount) {
|
||||||
|
// 使用mod函数检查余数是否接近0(考虑浮点数精度问题)
|
||||||
|
isHalfInterval = abs(mod(lineIndex, 2.0)) < 0.01;
|
||||||
|
if(isHalfInterval) {
|
||||||
|
secondaryLinesWidth = halfIntervalContourWidth;
|
||||||
|
}
|
||||||
|
// 使用mod函数检查余数是否接近0(考虑浮点数精度问题)
|
||||||
|
isIntermediate = abs(mod(lineIndex, 4.0)) < 0.01;
|
||||||
|
if(isIntermediate) {
|
||||||
|
secondaryLinesWidth = intermediateContourWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
|
#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
|
||||||
dFSecondary = max(dxc, dyc) * czm_pixelRatio * secondaryLinesWidth;
|
dFSecondary = max(dxc, dyc) * czm_pixelRatio * secondaryLinesWidth;
|
||||||
#else
|
#else
|
||||||
@ -203,10 +542,6 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|||||||
isSecondaryContour = (distanceToSecondaryContour < dFSecondary) && notCloseToMain;
|
isSecondaryContour = (distanceToSecondaryContour < dFSecondary) && notCloseToMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算当前高度所属的等高线高度
|
|
||||||
float mainContourHeight = floor(materialInput.height / spacing) * spacing;
|
|
||||||
float secondaryContourHeight = floor(materialInput.height / spacing * (secondaryLinesCount + 1.0)) * spacing / (secondaryLinesCount + 1.0);
|
|
||||||
|
|
||||||
// 高亮判断
|
// 高亮判断
|
||||||
bool shouldHighlight = false;
|
bool shouldHighlight = false;
|
||||||
if(isMainContour && abs(mainContourHeight - mouseHeight) < 0.5 * (spacing/(secondaryLinesCount+1.0))) {
|
if(isMainContour && abs(mainContourHeight - mouseHeight) < 0.5 * (spacing/(secondaryLinesCount+1.0))) {
|
||||||
@ -218,15 +553,41 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|||||||
// 颜色输出
|
// 颜色输出
|
||||||
vec4 outColor;
|
vec4 outColor;
|
||||||
if(shouldHighlight) {
|
if(shouldHighlight) {
|
||||||
outColor = vec4(1.0, 0.0, 0.0, 1.0);
|
outColor = czm_gammaCorrect(vec4(activeColor.rgb, activeColor.a));
|
||||||
} else if(isMainContour) {
|
} else if(isMainContour) {
|
||||||
outColor = czm_gammaCorrect(vec4(color.rgb, color.a));
|
float a = indexContourColor.a;
|
||||||
|
if(!indexContourShow) {
|
||||||
|
a = 0.0;
|
||||||
|
}
|
||||||
|
outColor = czm_gammaCorrect(vec4(indexContourColor.rgb, a));
|
||||||
} else if(isSecondaryContour) {
|
} else if(isSecondaryContour) {
|
||||||
outColor = czm_gammaCorrect(vec4(secondaryLinesColor.rgb, secondaryLinesColor.a));
|
float a = supplementaryContourColor.a;
|
||||||
|
if(!supplementaryContourShow) {
|
||||||
|
a = 0.0;
|
||||||
|
}
|
||||||
|
outColor = czm_gammaCorrect(vec4(supplementaryContourColor.rgb, a));
|
||||||
|
if(isHalfInterval) {
|
||||||
|
float a = halfIntervalContourColor.a;
|
||||||
|
if(!halfIntervalContourShow) {
|
||||||
|
a = 0.0;
|
||||||
|
}
|
||||||
|
outColor = czm_gammaCorrect(vec4(halfIntervalContourColor.rgb, a));
|
||||||
|
}
|
||||||
|
if(isIntermediate) {
|
||||||
|
float a = intermediateContourColor.a;
|
||||||
|
if(!intermediateContourShow) {
|
||||||
|
a = 0.0;
|
||||||
|
}
|
||||||
|
outColor = czm_gammaCorrect(vec4(intermediateContourColor.rgb, a));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
outColor = vec4(0.0);
|
outColor = vec4(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(materialInput.height<0.0) {
|
||||||
|
outColor = vec4(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
material.diffuse = outColor.rgb;
|
material.diffuse = outColor.rgb;
|
||||||
material.alpha = outColor.a;
|
material.alpha = outColor.a;
|
||||||
return material;
|
return material;
|
||||||
@ -237,14 +598,25 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|||||||
fabric: {
|
fabric: {
|
||||||
type: "ElevationContour",
|
type: "ElevationContour",
|
||||||
uniforms: {
|
uniforms: {
|
||||||
width: 2,
|
spacing: 10 * 5,
|
||||||
secondaryLinesWidth: 1, // 次级线宽度
|
activeColor: Cesium.Color.fromCssColorString(activeColor),
|
||||||
spacing: 200,
|
|
||||||
color: Cesium.Color.fromCssColorString('#ffd000'),
|
|
||||||
secondaryLinesColor: Cesium.Color.fromCssColorString('#0dff00').withAlpha(0.5),
|
|
||||||
mouseHeight: -100000,
|
mouseHeight: -100000,
|
||||||
mousePosition: new Cesium.Cartesian3(0, 0, 0),
|
mousePosition: new Cesium.Cartesian3(0, 0, 0),
|
||||||
secondaryLinesCount: 3
|
secondaryLinesCount: secondaryLinesCount,
|
||||||
|
cameraHeight: 0,
|
||||||
|
|
||||||
|
indexContourShow: indexContourShow,
|
||||||
|
indexContourWidth: indexContourWidth,
|
||||||
|
indexContourColor: Cesium.Color.fromCssColorString(indexContourColor),
|
||||||
|
intermediateContourShow: intermediateContourShow,
|
||||||
|
intermediateContourWidth: intermediateContourWidth,
|
||||||
|
intermediateContourColor: Cesium.Color.fromCssColorString(intermediateContourColor),
|
||||||
|
halfIntervalContourShow: halfIntervalContourShow,
|
||||||
|
halfIntervalContourWidth: halfIntervalContourWidth,
|
||||||
|
halfIntervalContourColor: Cesium.Color.fromCssColorString(halfIntervalContourColor),
|
||||||
|
supplementaryContourShow: supplementaryContourShow,
|
||||||
|
supplementaryContourWidth: supplementaryContourWidth,
|
||||||
|
supplementaryContourColor: Cesium.Color.fromCssColorString(supplementaryContourColor),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,15 +14,15 @@ function html() {
|
|||||||
<div class="div-item">
|
<div class="div-item">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input type="checkbox" name="isTotalTime" style="width: 16px; line-height: 15px; height: 15px; cursor: pointer; width: auto; margin-right: 5px;">
|
|
||||||
<span class="label">设置总时长</span>
|
<span class="label">设置总时长</span>
|
||||||
<div class="input-number input-number-unit-3">
|
<div class="input-number input-number-unit-3">
|
||||||
<input class="input total-time" type="number" title="" min="0" max="999999.99" step="0.01" name="totalTime" value="0">
|
<input class="input total-time" type="number" title="" min="0" max="999999.99" step="0.01" name="totalTime" value="0">
|
||||||
<span class="unit" style="top: 6px;">秒(s)</span>
|
<span class="unit" style="top: 6px;">秒(s)</span>
|
||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<button class="set-total-time-btn" style="margin-left: 5px;">应用</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="justify-content: flex-end;">
|
||||||
<input type="checkbox" name="repeat" style="width: 16px; line-height: 15px; height: 15px; cursor: pointer; width: auto; margin-right: 5px;">
|
<input type="checkbox" name="repeat" style="width: 16px; line-height: 15px; height: 15px; cursor: pointer; width: auto; margin-right: 5px;">
|
||||||
<span class="label">是否循环播放</span>
|
<span class="label">是否循环播放</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -135,14 +135,14 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
|
|||||||
pitch: viewer.camera.pitch,
|
pitch: viewer.camera.pitch,
|
||||||
roll: viewer.camera.roll
|
roll: viewer.camera.roll
|
||||||
}
|
}
|
||||||
|
tools.message({text: '操作成功'})
|
||||||
})
|
})
|
||||||
|
|
||||||
let totalTimeElm = contentElm.querySelector("input[name='totalTime']")
|
let totalTimeElm = contentElm.querySelector("input[name='totalTime']")
|
||||||
let isTotalTimeElm = contentElm.querySelector("input[name='isTotalTime']")
|
let setTotalTimeBtn = contentElm.getElementsByClassName('set-total-time-btn')[0]
|
||||||
let repeatElm = contentElm.querySelector("input[name='repeat']")
|
setTotalTimeBtn.addEventListener('click', () => {
|
||||||
isTotalTimeElm.addEventListener('change', () => {
|
if (points.length > 0) {
|
||||||
let trList = tableBody.getElementsByClassName('tr')
|
let trList = tableBody.getElementsByClassName('tr')
|
||||||
if (isTotalTimeElm.checked && trList.length > 0) {
|
|
||||||
let time = Number((Number(totalTimeElm.value) / (trList.length - 1)).toFixed(2))
|
let time = Number((Number(totalTimeElm.value) / (trList.length - 1)).toFixed(2))
|
||||||
for (let i = 0; i < trList.length - 1; i++) {
|
for (let i = 0; i < trList.length - 1; i++) {
|
||||||
points[i].duration = time
|
points[i].duration = time
|
||||||
@ -151,20 +151,12 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
|
|||||||
trList[trList.length - 1].querySelector("input[name='time']").value = 0
|
trList[trList.length - 1].querySelector("input[name='time']").value = 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
let repeatElm = contentElm.querySelector("input[name='repeat']")
|
||||||
totalTimeElm.addEventListener('blur', () => {
|
totalTimeElm.addEventListener('blur', () => {
|
||||||
let trList = tableBody.getElementsByClassName('tr')
|
|
||||||
totalTimeElm.value = Number(totalTimeElm.value)
|
totalTimeElm.value = Number(totalTimeElm.value)
|
||||||
if (totalTimeElm.value < 0) {
|
if (totalTimeElm.value < 0) {
|
||||||
totalTimeElm.value = 0
|
totalTimeElm.value = 0
|
||||||
}
|
}
|
||||||
if (isTotalTimeElm.checked && trList.length > 0) {
|
|
||||||
let time = Number((Number(totalTimeElm.value) / (trList.length - 1)).toFixed(2))
|
|
||||||
for (let i = 0; i < trList.length - 1; i++) {
|
|
||||||
points[i].duration = time
|
|
||||||
trList[i].querySelector("input[name='time']").value = time
|
|
||||||
}
|
|
||||||
trList[trList.length - 1].querySelector("input[name='time']").value = 0
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
repeatElm.checked = (repeat === Infinity ? true : false)
|
repeatElm.checked = (repeat === Infinity ? true : false)
|
||||||
repeatElm.addEventListener('change', () => {
|
repeatElm.addEventListener('change', () => {
|
||||||
@ -285,7 +277,6 @@ const open = async (sdk, options = {}, _Dialog = {}) => {
|
|||||||
// }
|
// }
|
||||||
})
|
})
|
||||||
e_time.addEventListener('input', (v) => {
|
e_time.addEventListener('input', (v) => {
|
||||||
isTotalTimeElm.checked = false
|
|
||||||
data.duration = Number(e_time.value)
|
data.duration = Number(e_time.value)
|
||||||
if (data.duration < 0) {
|
if (data.duration < 0) {
|
||||||
data.duration = 0
|
data.duration = 0
|
||||||
|
|||||||
@ -101,6 +101,7 @@ function getFlagFromKeyboard(key) {
|
|||||||
*/
|
*/
|
||||||
function keyDown(event) {
|
function keyDown(event) {
|
||||||
let _viewer = this
|
let _viewer = this
|
||||||
|
|
||||||
// 判断是否有输入框聚焦
|
// 判断是否有输入框聚焦
|
||||||
function isInputFocused() {
|
function isInputFocused() {
|
||||||
const activeElement = document.activeElement;
|
const activeElement = document.activeElement;
|
||||||
@ -164,33 +165,52 @@ function keyUp(event) {
|
|||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
function keyboardMapRoamingRender(_viewer) {
|
function keyboardMapRoamingRender(_viewer) {
|
||||||
if(!_viewer.scene.screenSpaceCameraController.enableTilt) {
|
if(!_viewer || !_viewer.scene || !_viewer.scene.screenSpaceCameraController.enableTilt) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let camera = _viewer.camera;
|
let camera = _viewer.camera;
|
||||||
let ellipsoid = _viewer.scene.globe.ellipsoid;
|
let ellipsoid = _viewer.scene.globe.ellipsoid;
|
||||||
let cameraHeight = ellipsoid.cartesianToCartographic(camera.position).height;
|
let cameraHeight = ellipsoid.cartesianToCartographic(camera.position).height;
|
||||||
|
let cameraHeight2 = camera.positionCartographic.height;
|
||||||
|
|
||||||
|
|
||||||
// 根据相机高度设置移动距离,比默认距离移动效果更好
|
// 根据相机高度设置移动距离,比默认距离移动效果更好
|
||||||
let moveRate = cameraHeight / 20.0;
|
let moveRate = cameraHeight / 20.0;
|
||||||
let rotationRate = moveRate / 500000 / Cesium.Math.toDegrees(camera.pitch);
|
let rotationRate = moveRate / 500000 / Cesium.Math.toDegrees(camera.pitch);
|
||||||
|
let moveRate2 = cameraHeight2 / 100.0;
|
||||||
|
|
||||||
if (flags.moveForward) {
|
if (flags.moveForward) {
|
||||||
// camera.moveForward(moveRate);
|
if(_viewer.scene.mode == 2) {
|
||||||
|
camera.moveUp(moveRate2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
camera.rotate(camera.right, -rotationRate);
|
camera.rotate(camera.right, -rotationRate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flags.moveBackward) {
|
if (flags.moveBackward) {
|
||||||
// camera.moveBackward(moveRate);
|
if(_viewer.scene.mode == 2) {
|
||||||
|
camera.moveDown(moveRate2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
camera.rotate(camera.right, rotationRate);
|
camera.rotate(camera.right, rotationRate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flags.moveLeft) {
|
if (flags.moveLeft) {
|
||||||
// camera.moveLeft(moveRate);
|
if(_viewer.scene.mode == 2) {
|
||||||
|
camera.moveLeft(moveRate2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
camera.rotate(camera.up, -rotationRate);
|
camera.rotate(camera.up, -rotationRate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flags.moveRight) {
|
if (flags.moveRight) {
|
||||||
// camera.moveRight(moveRate);
|
if(_viewer.scene.mode == 2) {
|
||||||
|
camera.moveRight(moveRate2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
camera.rotate(camera.up, rotationRate);
|
camera.rotate(camera.up, rotationRate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flags.moveUp) {
|
if (flags.moveUp) {
|
||||||
camera.moveUp(moveRate);
|
camera.moveUp(moveRate);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { getTemplateData } from './dataSource.js'
|
|||||||
let tools = new Tools();
|
let tools = new Tools();
|
||||||
|
|
||||||
|
|
||||||
async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
|
async function MapPrint(sdk, thumbnailImg, rectangle, originalImg, totalCanvas, scale) {
|
||||||
let exporting = false;
|
let exporting = false;
|
||||||
let templateData = getTemplateData(tools)
|
let templateData = getTemplateData(tools)
|
||||||
let _DialogObject
|
let _DialogObject
|
||||||
@ -263,7 +263,7 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
|
|||||||
updateCanvas()
|
updateCanvas()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let borderColorPicker = new ewPlugins('colorpicker', {
|
let borderColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('border-color')[0],
|
el: contentElm.getElementsByClassName('border-color')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: false, //是否开启透明度
|
alpha: false, //是否开启透明度
|
||||||
@ -290,21 +290,48 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
|
|||||||
|
|
||||||
let closeBtn
|
let closeBtn
|
||||||
let exportBtn
|
let exportBtn
|
||||||
|
let saveBtn
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
closeBtn = _DialogObject._element.foot.getElementsByClassName('close')[0]
|
closeBtn = _DialogObject._element.foot.getElementsByClassName('close')[0]
|
||||||
exportBtn = document.createElement('button')
|
exportBtn = document.createElement('button')
|
||||||
exportBtn.className = 'export';
|
exportBtn.className = 'export';
|
||||||
exportBtn.innerHTML = '打印';
|
exportBtn.innerHTML = '打印';
|
||||||
|
exportBtn.style.right = '150px'
|
||||||
leftElm.appendChild(closeBtn)
|
leftElm.appendChild(closeBtn)
|
||||||
leftElm.appendChild(exportBtn)
|
leftElm.appendChild(exportBtn)
|
||||||
|
saveBtn = document.createElement('button')
|
||||||
|
saveBtn.className = 'export';
|
||||||
|
saveBtn.innerHTML = '保存';
|
||||||
|
leftElm.appendChild(closeBtn)
|
||||||
|
leftElm.appendChild(saveBtn)
|
||||||
exportBtn.addEventListener('click', function () {
|
exportBtn.addEventListener('click', function () {
|
||||||
if (exporting) {
|
if (exporting) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
exporting = true
|
exporting = true
|
||||||
exportBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>打印'
|
exportBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>打印'
|
||||||
exportMap()
|
saveBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>保存'
|
||||||
|
exportMap('export')
|
||||||
|
// exporting = true
|
||||||
|
// exportBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>打印'
|
||||||
|
// let imgBlobData = canvas.toDataURL();
|
||||||
|
// let downloadElement = document.createElement('a');
|
||||||
|
// downloadElement.href = imgBlobData;
|
||||||
|
// downloadElement.download = `高清出图-${getDateTimeString()}.png`;
|
||||||
|
// document.body.appendChild(downloadElement);
|
||||||
|
// downloadElement.click();
|
||||||
|
// document.body.removeChild(downloadElement);
|
||||||
|
// URL.revokeObjectURL(imgBlobData);
|
||||||
|
})
|
||||||
|
saveBtn.addEventListener('click', function () {
|
||||||
|
if (exporting) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
exporting = true
|
||||||
|
exportBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>打印'
|
||||||
|
saveBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>保存'
|
||||||
|
exportMap('save')
|
||||||
// exporting = true
|
// exporting = true
|
||||||
// exportBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>打印'
|
// exportBtn.innerHTML = '<span style="position: absolute;width:100%;height:100%;top: 0;left: 0;border-radius: 3px;background-color: #6f89848f;"><svg class="icon-load"><use xlink:href="#yj-icon-load"></use></svg></span>打印'
|
||||||
// let imgBlobData = canvas.toDataURL();
|
// let imgBlobData = canvas.toDataURL();
|
||||||
@ -564,7 +591,7 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
|
|||||||
|
|
||||||
function changeMapBorderColor(color) {
|
function changeMapBorderColor(color) {
|
||||||
border.color = color || '#000000'
|
border.color = color || '#000000'
|
||||||
new ewPlugins('colorpicker', {
|
new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('border-color')[0],
|
el: contentElm.getElementsByClassName('border-color')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: false, //是否开启透明度
|
alpha: false, //是否开启透明度
|
||||||
@ -1197,12 +1224,52 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
|
|||||||
return `${year}${month}${day}${hours}${minutes}${seconds}${milliseconds}`;
|
return `${year}${month}${day}${hours}${minutes}${seconds}${milliseconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportMap() {
|
function exportMap(type) {
|
||||||
|
let iframeDoc = document
|
||||||
let unitDistance2
|
let unitDistance2
|
||||||
let canvas2 = document.createElement('canvas');
|
let iframe
|
||||||
|
if (type === 'export') {
|
||||||
|
iframe = document.createElement('iframe');
|
||||||
|
iframe.id = 'printIframe';
|
||||||
|
// iframe.src = 'print.html';
|
||||||
|
iframe.frameborder = '0';
|
||||||
|
iframe.style.position = 'absolute';
|
||||||
|
iframe.style.zIndex = '-9999999';
|
||||||
|
iframe.style.width = '100vw';
|
||||||
|
iframe.style.height = '100vh';
|
||||||
|
iframe.style.left = '0';
|
||||||
|
iframe.style.top = '0';
|
||||||
|
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
||||||
|
}
|
||||||
|
|
||||||
|
let canvas2 = iframeDoc.createElement('canvas');
|
||||||
|
if (type === 'export') {
|
||||||
|
canvas2.style.width = '100%'
|
||||||
|
canvas2.style.height = '100%'
|
||||||
|
canvas2.style.objectFit = 'contain';
|
||||||
|
iframeDoc.body.appendChild(canvas2);
|
||||||
|
}
|
||||||
|
|
||||||
let ctx2 = canvas2.getContext('2d');
|
let ctx2 = canvas2.getContext('2d');
|
||||||
let imgElm2 = new Image();
|
let imgElm2 = new Image();
|
||||||
|
if (type === 'export') {
|
||||||
|
const tempCanvas = document.createElement('canvas');
|
||||||
|
const tempCtx = tempCanvas.getContext('2d');
|
||||||
|
if(scale>=3) {
|
||||||
|
tempCanvas.width = totalCanvas.width / scale * 2
|
||||||
|
tempCanvas.height = totalCanvas.height / scale * 2
|
||||||
|
tempCtx.drawImage(totalCanvas, 0, 0, tempCanvas.width, tempCanvas.height);
|
||||||
|
imgElm2.src = tempCanvas.toDataURL('image/jpeg', 0.95)
|
||||||
|
}
|
||||||
|
else {
|
||||||
imgElm2.src = originalImg
|
imgElm2.src = originalImg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
imgElm2.src = originalImg
|
||||||
|
}
|
||||||
imgElm2.onload = function () {
|
imgElm2.onload = function () {
|
||||||
if (isLoad) {
|
if (isLoad) {
|
||||||
return
|
return
|
||||||
@ -1416,17 +1483,36 @@ async function MapPrint(sdk, thumbnailImg, rectangle, originalImg) {
|
|||||||
|
|
||||||
// 在释放资源后执行回调
|
// 在释放资源后执行回调
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (type === 'export') {
|
||||||
|
const iframeWindow = iframe.contentWindow;
|
||||||
|
if (iframeWindow && typeof iframeWindow.print === 'function') {
|
||||||
|
iframeWindow.addEventListener('afterprint', function () {
|
||||||
|
document.body.removeChild(iframe)
|
||||||
|
})
|
||||||
|
iframeWindow.print();
|
||||||
|
} else {
|
||||||
|
console.error('打印失败,请手动保存截图');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
canvas2.toBlob(function (blob) {
|
canvas2.toBlob(function (blob) {
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
let downloadElement = document.createElement('a');
|
let downloadElement = document.createElement('a');
|
||||||
downloadElement.href = url;
|
downloadElement.href = url;
|
||||||
downloadElement.download = `高清出图-${getDateTimeString()}.jpg`;
|
downloadElement.download = `高清出图-${getDateTimeString()}.png`;
|
||||||
document.body.appendChild(downloadElement);
|
document.body.appendChild(downloadElement);
|
||||||
downloadElement.click();
|
downloadElement.click();
|
||||||
document.body.removeChild(downloadElement);
|
document.body.removeChild(downloadElement);
|
||||||
}, 'image/jpeg', 0.95);
|
URL.revokeObjectURL(url);
|
||||||
|
}, 'image/png', 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
exporting = false;
|
exporting = false;
|
||||||
exportBtn.innerHTML = '打印';
|
exportBtn.innerHTML = '打印';
|
||||||
|
saveBtn.innerHTML = '保存';
|
||||||
// canvas2.toBlob(function (blob) {
|
// canvas2.toBlob(function (blob) {
|
||||||
// let imgBlobData = URL.createObjectURL(blob);
|
// let imgBlobData = URL.createObjectURL(blob);
|
||||||
// let downloadElement = document.createElement('a');
|
// let downloadElement = document.createElement('a');
|
||||||
|
|||||||
@ -124,7 +124,7 @@ function syncViewer() {
|
|||||||
if (height > 9000000) {
|
if (height > 9000000) {
|
||||||
height = 9000000
|
height = 9000000
|
||||||
}
|
}
|
||||||
if (height < 100000) {
|
if (height < 400000) {
|
||||||
this.entity.billboard.show = true
|
this.entity.billboard.show = true
|
||||||
this.entity.rectangle.show = false
|
this.entity.rectangle.show = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,18 +4,38 @@
|
|||||||
import Tools from "../../Tools";
|
import Tools from "../../Tools";
|
||||||
import { getCoordinateSystem } from "../../Global/global";
|
import { getCoordinateSystem } from "../../Global/global";
|
||||||
import MouseEvent from '../../Event/index'
|
import MouseEvent from '../../Event/index'
|
||||||
|
import { getSdk as get2DSdk } from '../../Global/MultiViewportMode'
|
||||||
|
import { getSdk as getSplitScreenSdk } from "../../Global/SplitScreen";
|
||||||
|
|
||||||
let event
|
let event
|
||||||
|
let event2
|
||||||
let MouseCoordinateElm
|
let MouseCoordinateElm
|
||||||
let requestAnimationFrameEventId
|
let requestAnimationFrameEventId
|
||||||
|
let tmovement
|
||||||
|
let targetSdk
|
||||||
|
let sdkD
|
||||||
|
|
||||||
const MouseCoordinate = (sdk, status) => {
|
const MouseCoordinate = (sdk, status) => {
|
||||||
|
if (!sdk || !sdk.viewer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
targetSdk = sdk
|
||||||
|
sdkD = get2DSdk().sdkD
|
||||||
|
if(!sdkD) {
|
||||||
|
sdkD = getSplitScreenSdk().sdkD
|
||||||
|
}
|
||||||
|
|
||||||
let tools = new Tools(sdk)
|
let tools = new Tools(sdk)
|
||||||
if (status) {
|
if (status) {
|
||||||
if (event) {
|
if (event) {
|
||||||
event.destroy()
|
event.destroy()
|
||||||
}
|
}
|
||||||
|
if (event2) {
|
||||||
|
event2.destroy()
|
||||||
|
event2 = undefined
|
||||||
|
}
|
||||||
event = new MouseEvent(sdk)
|
event = new MouseEvent(sdk)
|
||||||
|
tmovement = null
|
||||||
let position = {
|
let position = {
|
||||||
x: '',
|
x: '',
|
||||||
y: '',
|
y: '',
|
||||||
@ -40,22 +60,60 @@ const MouseCoordinate = (sdk, status) => {
|
|||||||
contentElm.style['background-size'] = `200% 200%`;
|
contentElm.style['background-size'] = `200% 200%`;
|
||||||
MouseCoordinateElm = contentElm
|
MouseCoordinateElm = contentElm
|
||||||
}
|
}
|
||||||
sdk.viewer._element.appendChild(contentElm)
|
sdk.viewer.container.appendChild(contentElm)
|
||||||
let tmovement
|
|
||||||
event.mouse_move((movement, cartesian) => {
|
event.mouse_move((movement, cartesian) => {
|
||||||
tmovement = { ...movement }
|
targetSdk = sdk
|
||||||
|
tmovement = { ...movement.endPosition }
|
||||||
})
|
})
|
||||||
|
|
||||||
const getPosition = () => {
|
const getPosition = () => {
|
||||||
if(!tmovement) {
|
if (!targetSdk) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let canvas = sdk.viewer._element.getElementsByTagName('canvas')[0]
|
let canvas = sdk.viewer._element.getElementsByTagName('canvas')[0]
|
||||||
let left = tmovement.endPosition.x;
|
sdkD = get2DSdk().sdkD
|
||||||
let top = tmovement.endPosition.y;
|
if(!sdkD) {
|
||||||
let cartesian = event.getcartesian(tmovement)
|
sdkD = getSplitScreenSdk().sdkD
|
||||||
contentElm.style['background-position-x'] = `${-canvas.width + left + 4}px`;
|
}
|
||||||
contentElm.style['background-position-y'] = `${-canvas.height + top - 2}px`;
|
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
|
// this.entity.position = cartesian
|
||||||
if (cartesian) {
|
if (cartesian) {
|
||||||
let degrees = tools.cartesian3Towgs84(cartesian, sdk.viewer)
|
let degrees = tools.cartesian3Towgs84(cartesian, sdk.viewer)
|
||||||
@ -97,10 +155,13 @@ const MouseCoordinate = (sdk, status) => {
|
|||||||
else {
|
else {
|
||||||
if (event) {
|
if (event) {
|
||||||
event.destroy()
|
event.destroy()
|
||||||
event = undefined
|
}
|
||||||
|
if (event2) {
|
||||||
|
event2.destroy()
|
||||||
|
event2 = undefined
|
||||||
}
|
}
|
||||||
if (MouseCoordinateElm) {
|
if (MouseCoordinateElm) {
|
||||||
sdk.viewer._element.removeChild(MouseCoordinateElm)
|
sdk.viewer.container.removeChild(MouseCoordinateElm)
|
||||||
MouseCoordinateElm = undefined
|
MouseCoordinateElm = undefined
|
||||||
}
|
}
|
||||||
if (requestAnimationFrameEventId) {
|
if (requestAnimationFrameEventId) {
|
||||||
|
|||||||
578
src/Global/MultiViewportMode/ClickCallback/index.js
Normal file
578
src/Global/MultiViewportMode/ClickCallback/index.js
Normal file
@ -0,0 +1,578 @@
|
|||||||
|
/**
|
||||||
|
* @name: click
|
||||||
|
* @author: Administrator
|
||||||
|
* @date: 2023-05-28 11:05
|
||||||
|
* @description:click
|
||||||
|
* @update: 2023-05-28 11:05
|
||||||
|
*/
|
||||||
|
let leftClickHandler = null
|
||||||
|
let rightClickHandler = null
|
||||||
|
let MoveHandler = null
|
||||||
|
let leftClickCallbackMap = new Map()
|
||||||
|
let rightClickCallbackMap = new Map()
|
||||||
|
let MoveCallbackMap = new Map()
|
||||||
|
let selectedFeature;
|
||||||
|
|
||||||
|
|
||||||
|
function cartesian3Towgs84(cartesian, viewer) {
|
||||||
|
var ellipsoid = viewer.scene.globe.ellipsoid
|
||||||
|
var cartesian3 = new Cesium.Cartesian3(
|
||||||
|
cartesian.x,
|
||||||
|
cartesian.y,
|
||||||
|
cartesian.z
|
||||||
|
)
|
||||||
|
var cartographic = ellipsoid.cartesianToCartographic(cartesian3)
|
||||||
|
var lat = Cesium.Math.toDegrees(cartographic.latitude)
|
||||||
|
var lng = Cesium.Math.toDegrees(cartographic.longitude)
|
||||||
|
var alt = cartographic.height < 0 ? 0 : cartographic.height
|
||||||
|
return {
|
||||||
|
lng: lng,
|
||||||
|
lat: lat,
|
||||||
|
alt: alt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getcartesian(sdk, movement) {
|
||||||
|
if (movement.endPosition) {
|
||||||
|
movement.endPosition.y -= 2
|
||||||
|
}
|
||||||
|
let position = movement.position || movement.endPosition
|
||||||
|
// 获取世界坐标系地表坐标,考虑地形,不包括模型,倾斜摄影模型表面;
|
||||||
|
let cartesian = sdk.viewer.scene.pickPosition(position)
|
||||||
|
if (!cartesian) {
|
||||||
|
const ray = sdk.viewer.camera.getPickRay(position); //相交的射线
|
||||||
|
cartesian = sdk.viewer.scene.globe.pick(ray, sdk.viewer.scene);
|
||||||
|
}
|
||||||
|
return cartesian
|
||||||
|
}
|
||||||
|
|
||||||
|
function openLeftClick(sdk, cb) {
|
||||||
|
if (!sdk || !sdk.viewer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let click = true
|
||||||
|
leftClickHandler = new Cesium.ScreenSpaceEventHandler(sdk.viewer.canvas)
|
||||||
|
leftClickHandler.setInputAction((movement) => {
|
||||||
|
let cartesian = sdk.viewer.scene.pickPosition(movement.position)
|
||||||
|
if (!cartesian) {
|
||||||
|
const ray = sdk.viewer.camera.getPickRay(movement.position); //相交的射线
|
||||||
|
cartesian = sdk.viewer.scene.globe.pick(ray, sdk.viewer.scene);
|
||||||
|
}
|
||||||
|
if (!cartesian) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let pos84 = cartesian3Towgs84(cartesian, sdk.viewer)
|
||||||
|
|
||||||
|
cb && cb(pos84)
|
||||||
|
|
||||||
|
if (click) {
|
||||||
|
click = false
|
||||||
|
setTimeout(() => {
|
||||||
|
click = true
|
||||||
|
}, 600);
|
||||||
|
if (!YJ.Measure.GetMeasureStatus() && cartesian) {
|
||||||
|
let flag = false
|
||||||
|
for (let i = leftClickCallbackMap.size - 1; i >= 0; i--) {
|
||||||
|
let key = Array.from(leftClickCallbackMap.keys())[i]
|
||||||
|
let obj = leftClickCallbackMap.get(key)
|
||||||
|
if (obj) {
|
||||||
|
|
||||||
|
if (obj.that) {
|
||||||
|
// 是否为多边形
|
||||||
|
if (obj.that.type === 'PolygonObject') {
|
||||||
|
// 是否可点击y
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.options.positions && obj.that.options.positions.length >= 3) {
|
||||||
|
let pt = turf.point([pos84.lng, pos84.lat]);
|
||||||
|
let polyPos = []
|
||||||
|
for (let i = 0; i < obj.that.options.positions.length; i++) {
|
||||||
|
polyPos.push([
|
||||||
|
obj.that.options.positions[i].lng,
|
||||||
|
obj.that.options.positions[i].lat
|
||||||
|
])
|
||||||
|
}
|
||||||
|
polyPos.push([
|
||||||
|
obj.that.options.positions[0].lng,
|
||||||
|
obj.that.options.positions[0].lat
|
||||||
|
])
|
||||||
|
let poly = turf.polygon([polyPos]);
|
||||||
|
let contain = turf.booleanPointInPolygon(pt, poly);
|
||||||
|
if (contain) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.options.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 聚集地
|
||||||
|
else if (obj.that.type === 'AssembleObject') {
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.options.positions && obj.that.options.positions.length >= 3) {
|
||||||
|
let positions = obj.that.computeAssemble(obj.that.options.positions, true)
|
||||||
|
let pt = turf.point([pos84.lng, pos84.lat]);
|
||||||
|
let polyPos = []
|
||||||
|
for (let i = 0; i < positions.length; i += 2) {
|
||||||
|
polyPos.push([
|
||||||
|
positions[i],
|
||||||
|
positions[i + 1]
|
||||||
|
])
|
||||||
|
}
|
||||||
|
let poly = turf.polygon([polyPos]);
|
||||||
|
let contain = turf.booleanPointInPolygon(pt, poly);
|
||||||
|
if (contain) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.options.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 单箭头
|
||||||
|
else if (obj.that.type === 'AttackArrowObject') {
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.options.positions && obj.that.options.positions.length >= 3) {
|
||||||
|
let pt = turf.point([pos84.lng, pos84.lat]);
|
||||||
|
let positions = obj.that.computeAttackArrow(obj.that.options.positions)
|
||||||
|
let polyPos = []
|
||||||
|
for (let m = 0; m < positions.length; m++) {
|
||||||
|
let pos84 = cartesian3Towgs84(positions[m], sdk.viewer)
|
||||||
|
polyPos.push([pos84.lng, pos84.lat])
|
||||||
|
}
|
||||||
|
let poly = turf.polygon([polyPos]);
|
||||||
|
let contain = turf.booleanPointInPolygon(pt, poly);
|
||||||
|
if (contain) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.options.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 双箭头
|
||||||
|
else if (obj.that.type === 'PincerArrowObject') {
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.options.positions && obj.that.options.positions.length >= 5) {
|
||||||
|
let pt = turf.point([pos84.lng, pos84.lat]);
|
||||||
|
let positions = obj.that.computePincerArrow(obj.that.options.positions)
|
||||||
|
let polyPos = []
|
||||||
|
for (let m = 0; m < positions.length; m++) {
|
||||||
|
let pos84 = cartesian3Towgs84(positions[m], sdk.viewer)
|
||||||
|
polyPos.push([pos84.lng, pos84.lat])
|
||||||
|
}
|
||||||
|
let pos84_0 = cartesian3Towgs84(positions[0], sdk.viewer)
|
||||||
|
polyPos.push([pos84_0.lng, pos84_0.lat])
|
||||||
|
let poly = turf.polygon([polyPos]);
|
||||||
|
let contain = turf.booleanPointInPolygon(pt, poly);
|
||||||
|
if (contain) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.options.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 圆
|
||||||
|
else if (obj.that.type === 'CircleObject') {
|
||||||
|
if (obj.that.picking) {
|
||||||
|
let pt = turf.point([pos84.lng, pos84.lat]);
|
||||||
|
if (obj.that.options.center && obj.that.options.radius) {
|
||||||
|
let center = [obj.that.options.center.lng, obj.that.options.center.lat];
|
||||||
|
let radius = obj.that.options.radius / 1000;
|
||||||
|
let options = { steps: 360, units: 'kilometers' };
|
||||||
|
let circle = turf.circle(center, radius, options);
|
||||||
|
let contain = turf.booleanPointInPolygon(pt, circle);
|
||||||
|
if (contain) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.options.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 扇形
|
||||||
|
else if (obj.that.type === 'SectorObject') {
|
||||||
|
if (obj.that.picking) {
|
||||||
|
let pt = turf.point([pos84.lng, pos84.lat]);
|
||||||
|
if (obj.that.options.center && obj.that.options.radius && obj.that.options.startAngle && obj.that.options.endAngle) {
|
||||||
|
let positions = obj.that.calSector(obj.that.options.center, obj.that.options.radius, obj.that.options.startAngle, obj.that.options.endAngle, undefined, true)
|
||||||
|
let polyPos = []
|
||||||
|
for (let m = 0; m < positions.length; m++) {
|
||||||
|
polyPos.push([positions[m].lng, positions[m].lat])
|
||||||
|
}
|
||||||
|
let poly = turf.polygon([polyPos]);
|
||||||
|
let contain = turf.booleanPointInPolygon(pt, poly);
|
||||||
|
if (contain) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.options.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
flag = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag) {
|
||||||
|
const pick = sdk.viewer.scene.pick(movement.position)
|
||||||
|
if (pick) {
|
||||||
|
if (pick.id) {
|
||||||
|
let entityId
|
||||||
|
// 矢量
|
||||||
|
if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) {
|
||||||
|
let obj = leftClickCallbackMap.get(pick.id.parentId)
|
||||||
|
if (obj.that.picking && obj.that.geojson) {
|
||||||
|
for (let i = 0; i < obj.that.geojson.features.length; i++) {
|
||||||
|
if (obj.that.geojson.features[i].id === pick.id._id) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.geojson.features[i].id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (typeof pick.id.id == 'string') {
|
||||||
|
let array = pick.id.id.split('-')
|
||||||
|
array.splice(array.length - 1, 1)
|
||||||
|
entityId = array.join('-')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pick.id.properties && pick.id.properties.id && leftClickCallbackMap.has(pick.id.properties.id._value)) {
|
||||||
|
let obj = leftClickCallbackMap.get(pick.id.properties.id._value)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.id.properties.id._value,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (leftClickCallbackMap.has(pick.id.id)) {
|
||||||
|
let obj = leftClickCallbackMap.get(pick.id.id)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.id.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (entityId && leftClickCallbackMap.has(entityId)) {
|
||||||
|
let obj = leftClickCallbackMap.get(entityId)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
entityId,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (pick.primitive) {
|
||||||
|
if (typeof pick.id == 'string' && leftClickCallbackMap.has(pick.id)) {
|
||||||
|
let obj = leftClickCallbackMap.get(pick.id)
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (pick.primitive && pick.primitive.id) {
|
||||||
|
if (leftClickCallbackMap.has(pick.primitive.id)) {
|
||||||
|
let obj = leftClickCallbackMap.get(pick.primitive.id)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.type === 'bim') {
|
||||||
|
if (YJ.Global.getBimPickStatus(sdk)) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.primitive,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.primitive.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pick.content && (!pick.primitive || !pick.primitive.id)) {
|
||||||
|
if (leftClickCallbackMap.has(pick.content.tileset.id)) {
|
||||||
|
let obj = leftClickCallbackMap.get(pick.content.tileset.id)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.type === 'bim') {
|
||||||
|
if (YJ.Global.getBimPickStatus(sdk)) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.content.tileset,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.content.tileset.id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// if (click) {
|
||||||
|
// click = false
|
||||||
|
// setTimeout(() => {
|
||||||
|
// click = true
|
||||||
|
// }, 300);
|
||||||
|
// if (!YJ.Measure.GetMeasureStatus()) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
||||||
|
|
||||||
|
// leftClickHandler.setInputAction(function (movement) {
|
||||||
|
// const feature = sdk.viewer.scene.pick(movement.endPosition);
|
||||||
|
// // unselectFeature(selectedFeature);
|
||||||
|
// if (selectedFeature) {
|
||||||
|
// selectedFeature.color = Cesium.Color.WHITE;
|
||||||
|
// }
|
||||||
|
// selectedFeature = feature
|
||||||
|
// if (feature) {
|
||||||
|
// feature.color = Cesium.Color.YELLOW;
|
||||||
|
// }
|
||||||
|
// }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeLeftClick(sdk) {
|
||||||
|
leftClickHandler.destroy() //关闭事件句柄
|
||||||
|
leftClickHandler = null
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
function openRightClick(sdk) {
|
||||||
|
if (!sdk || !sdk.viewer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rightClickHandler = new Cesium.ScreenSpaceEventHandler(sdk.viewer.canvas)
|
||||||
|
rightClickHandler.setInputAction((movement) => {
|
||||||
|
if (!YJ.Measure.GetMeasureStatus()) {
|
||||||
|
const pick = sdk.viewer.scene.pick(movement.position)
|
||||||
|
if (pick && pick.id) {
|
||||||
|
let id
|
||||||
|
if (pick.id.type && pick.id.type === 'vector' && pick.id.parentId) {
|
||||||
|
let obj = rightClickCallbackMap.get(pick.id.parentId)
|
||||||
|
if (obj.that.picking && obj.that.geojson) {
|
||||||
|
for (let i = 0; i < obj.that.geojson.features.length; i++) {
|
||||||
|
if (obj.that.geojson.features[i].id === pick.id._id) {
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
obj.that.geojson.features[i].id,
|
||||||
|
cartesian3Towgs84(getcartesian(sdk, movement), sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (typeof pick.id === 'string') {
|
||||||
|
id = pick.id
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
id = pick.id.id
|
||||||
|
}
|
||||||
|
if (rightClickCallbackMap.has(id)) {
|
||||||
|
let obj = rightClickCallbackMap.get(id)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
let cartesian = getcartesian(sdk, movement)
|
||||||
|
if (!cartesian) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
id,
|
||||||
|
cartesian3Towgs84(cartesian, sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pick && pick.content) {
|
||||||
|
if (rightClickCallbackMap.has(pick.content.tileset.id)) {
|
||||||
|
let obj = rightClickCallbackMap.get(pick.content.tileset.id)
|
||||||
|
if (obj.that.picking) {
|
||||||
|
if (obj.that.type === 'bim') {
|
||||||
|
if (YJ.Global.getBimPickStatus(sdk)) {
|
||||||
|
let cartesian = getcartesian(sdk, movement)
|
||||||
|
if (!cartesian) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.getProperty('id'),
|
||||||
|
cartesian3Towgs84(cartesian, sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let cartesian = getcartesian(sdk, movement)
|
||||||
|
if (!cartesian) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
obj.callback(
|
||||||
|
movement,
|
||||||
|
pick.content.tileset.id,
|
||||||
|
cartesian3Towgs84(cartesian, sdk.viewer), obj.that)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK)
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeRightClick() {
|
||||||
|
if (rightClickHandler) {
|
||||||
|
rightClickHandler.destroy() //关闭事件句柄
|
||||||
|
rightClickHandler = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMove(sdk) {
|
||||||
|
MoveHandler = new Cesium.ScreenSpaceEventHandler(sdk.viewer.canvas)
|
||||||
|
MoveHandler.setInputAction(function (movement) {
|
||||||
|
const pick = sdk.viewer.scene.pick(movement.endPosition);
|
||||||
|
// unselectFeature(selectedFeature);
|
||||||
|
// if (selectedFeature) {
|
||||||
|
// let color = '#fff'
|
||||||
|
// let state = selectedFeature.getProperty('state')
|
||||||
|
// switch (state) {
|
||||||
|
// case '0':
|
||||||
|
// color = '#fff'
|
||||||
|
// break;
|
||||||
|
// case '1':
|
||||||
|
// color = '#f00'
|
||||||
|
// break;
|
||||||
|
// case '2':
|
||||||
|
// color = '#0f0'
|
||||||
|
// break;
|
||||||
|
// case '3':
|
||||||
|
// color = '#00f'
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// }
|
||||||
|
// selectedFeature.color = Cesium.Color.fromCssColorString(color).withAlpha(selectedFeature.tileset.transparency)
|
||||||
|
// }
|
||||||
|
// if (pick && pick.id) { }
|
||||||
|
// if (pick && pick.content) {
|
||||||
|
// if (MoveCallbackMap.has(pick.content.tileset.id)) {
|
||||||
|
// let obj = MoveCallbackMap.get(pick.content.tileset.id)
|
||||||
|
// if (obj.that.picking) {
|
||||||
|
// if (obj.that.type === 'bim') {
|
||||||
|
// if (YJ.Global.getBimPickStatus(sdk)) {
|
||||||
|
// selectedFeature = pick
|
||||||
|
// pick.color = Cesium.Color.YELLOW;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// selectedFeature = null
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// selectedFeature = pick
|
||||||
|
// pick.color = Cesium.Color.YELLOW;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// selectedFeature = null
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeMove() {
|
||||||
|
if (MoveHandler) {
|
||||||
|
MoveHandler.destroy() //关闭事件句柄
|
||||||
|
MoveHandler = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*注册左键回调*/
|
||||||
|
function regLeftClickCallback(id, callback, that) {
|
||||||
|
|
||||||
|
leftClickCallbackMap.set(id, { callback, that })
|
||||||
|
}/*取消左键回调*/
|
||||||
|
function unRegLeftClickCallback(id,) {
|
||||||
|
leftClickCallbackMap.delete(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*注册右键回调*/
|
||||||
|
function regRightClickCallback(id, callback, that) {
|
||||||
|
rightClickCallbackMap.set(id, { callback, that })
|
||||||
|
}/*取消右键回调*/
|
||||||
|
function unRegRightClickCallback(id,) {
|
||||||
|
rightClickCallbackMap.delete(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*注册左键回调*/
|
||||||
|
function regMoveCallback(id, callback, that) {
|
||||||
|
MoveCallbackMap.set(id, { callback, that })
|
||||||
|
}/*取消左键回调*/
|
||||||
|
function unregMoveCallback(id,) {
|
||||||
|
MoveCallbackMap.delete(id,)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLeftClickState() {
|
||||||
|
if (leftClickHandler) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRightClickState() {
|
||||||
|
if (rightClickHandler) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMoveState() {
|
||||||
|
if (MoveHandler) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export { openLeftClick, closeLeftClick, regLeftClickCallback, unRegLeftClickCallback, openRightClick, closeRightClick, regRightClickCallback, unRegRightClickCallback, openMove, closeMove, regMoveCallback, unregMoveCallback, getLeftClickState, getRightClickState, getMoveState }
|
||||||
@ -7,6 +7,9 @@ import { CesiumContainer } from '../global'
|
|||||||
import { off as offSplitScreen } from "../SplitScreen";
|
import { off as offSplitScreen } from "../SplitScreen";
|
||||||
import { FlwStatusSwitch, JwwStatusSwitch, getFlwStatus, getJwwStatus } from "../global"
|
import { FlwStatusSwitch, JwwStatusSwitch, getFlwStatus, getJwwStatus } from "../global"
|
||||||
import { SheetIndexStatusSwitch, getStatus } from '../SheetIndex'
|
import { SheetIndexStatusSwitch, getStatus } from '../SheetIndex'
|
||||||
|
import { getLeftClickState, getRightClickState, getMoveState } from "../../Global/ClickCallback"
|
||||||
|
import { openLeftClick, openRightClick, openMove } from "./ClickCallback"
|
||||||
|
|
||||||
|
|
||||||
let sdk2D
|
let sdk2D
|
||||||
let sdk3D
|
let sdk3D
|
||||||
@ -32,6 +35,16 @@ async function init(sdk) {
|
|||||||
})
|
})
|
||||||
sdk2.viewer.scene.mode = Cesium.SceneMode.SCENE2D
|
sdk2.viewer.scene.mode = Cesium.SceneMode.SCENE2D
|
||||||
sdk2D = await sdk2
|
sdk2D = await sdk2
|
||||||
|
if(getLeftClickState()) {
|
||||||
|
openLeftClick(sdk2D)
|
||||||
|
}
|
||||||
|
if(getRightClickState()) {
|
||||||
|
openRightClick(sdk2D)
|
||||||
|
}
|
||||||
|
if(getMoveState()) {
|
||||||
|
openMove(sdk2D)
|
||||||
|
}
|
||||||
|
|
||||||
// window.sdk2D = sdk2D
|
// window.sdk2D = sdk2D
|
||||||
solveBug()
|
solveBug()
|
||||||
syncObject = { sdks: [sdk, sdk2], tools }
|
syncObject = { sdks: [sdk, sdk2], tools }
|
||||||
@ -49,7 +62,16 @@ async function init(sdk) {
|
|||||||
sdk2D.viewer.imageryLayers.removeAll()
|
sdk2D.viewer.imageryLayers.removeAll()
|
||||||
for (let i = 0; i < imageryLayers.length; i++) {
|
for (let i = 0; i < imageryLayers.length; i++) {
|
||||||
let entity = sdk2D.viewer.imageryLayers.addImageryProvider(imageryLayers[i].imageryProvider, imageryLayers[i]._layerIndex)
|
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.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.entities.collectionChanged.addEventListener(syncEntities)
|
||||||
// sdk.viewer.dataSources.dataSourceAdded.addEventListener(syncDataSources)
|
// sdk.viewer.dataSources.dataSourceAdded.addEventListener(syncDataSources)
|
||||||
@ -61,6 +83,12 @@ async function init(sdk) {
|
|||||||
JwwStatusSwitch(sdk2, true)
|
JwwStatusSwitch(sdk2, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdk.entityMap.forEach((item, key) => {
|
||||||
|
if (item.showView == 2) {
|
||||||
|
item.showView = 2
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
async function on(sdk) {
|
async function on(sdk) {
|
||||||
if (sdk2D) {
|
if (sdk2D) {
|
||||||
@ -94,6 +122,11 @@ function off(sdk) {
|
|||||||
activeViewer = null
|
activeViewer = null
|
||||||
syncObject = {}
|
syncObject = {}
|
||||||
}
|
}
|
||||||
|
sdk.entityMap.forEach((item, key) => {
|
||||||
|
if (item.showView) {
|
||||||
|
item.show = item.show
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncData2(sdk, id, entityId) {
|
async function syncData2(sdk, id, entityId) {
|
||||||
@ -119,8 +152,17 @@ async function syncData2(sdk, id, entityId) {
|
|||||||
options.heightMode = 0
|
options.heightMode = 0
|
||||||
options.height = 0
|
options.height = 0
|
||||||
}
|
}
|
||||||
if (!that.type || (that.type !== 'tileset' && that.type !== 'bim' && that.type !== 'glb' && that.type !== 'layer')) {
|
|
||||||
let newObject = await new that.constructor(sdk2D, options)
|
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 callback
|
||||||
|
if(that.type === 'TextBox') {
|
||||||
|
callback = that.callback
|
||||||
|
}
|
||||||
|
|
||||||
|
let newObject = await new that.constructor(sdk2D, options, callback)
|
||||||
newObject.onClick = that.onClick
|
newObject.onClick = that.onClick
|
||||||
newObject.onRightClick = that.onRightClick
|
newObject.onRightClick = that.onRightClick
|
||||||
newObject.onMouseMove = that.onMouseMove
|
newObject.onMouseMove = that.onMouseMove
|
||||||
@ -207,8 +249,19 @@ async function syncData2(sdk, id, entityId) {
|
|||||||
obj.options.heightReference = 1
|
obj.options.heightReference = 1
|
||||||
}
|
}
|
||||||
let options = syncObject.tools.deepCopyObj(obj.options)
|
let options = syncObject.tools.deepCopyObj(obj.options)
|
||||||
if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer')) {
|
if (!obj.type || (obj.type !== 'tileset' && obj.type !== 'bim' && obj.type !== 'glb' && obj.type !== 'layer' && obj.type !== 'wallStereoscopic')) {
|
||||||
let target = await new obj.constructor(sdk2D, options)
|
if (obj.showView == 3) {
|
||||||
|
options.show = false
|
||||||
|
}
|
||||||
|
let target = await sdk2D.entityMap.get(options.id)
|
||||||
|
if(target) {
|
||||||
|
await target.remove()
|
||||||
|
}
|
||||||
|
let callback
|
||||||
|
if(obj.type === 'TextBox') {
|
||||||
|
callback = obj.callback
|
||||||
|
}
|
||||||
|
target = await new obj.constructor(sdk2D, options, callback)
|
||||||
target.onClick = obj.onClick
|
target.onClick = obj.onClick
|
||||||
target.onRightClick = obj.onRightClick
|
target.onRightClick = obj.onRightClick
|
||||||
target.onMouseMove = obj.onMouseMove
|
target.onMouseMove = obj.onMouseMove
|
||||||
@ -401,12 +454,26 @@ function syncImageryLayerRemoved(layer, index) {
|
|||||||
sdk2D.viewer.imageryLayers.remove(layer2d)
|
sdk2D.viewer.imageryLayers.remove(layer2d)
|
||||||
}
|
}
|
||||||
function syncImageryLayerShownOrHidden(layer, index, state) {
|
function syncImageryLayerShownOrHidden(layer, index, state) {
|
||||||
|
return
|
||||||
let layer2d = sdk2D.viewer.imageryLayers._layers[index]
|
let layer2d = sdk2D.viewer.imageryLayers._layers[index]
|
||||||
|
let layer3d = sdk3D.viewer.imageryLayers._layers[index]
|
||||||
|
console.log('layer2d', layer2d, sdk2D, layer3d)
|
||||||
|
|
||||||
if (!layer2d) {
|
if (!layer2d) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (layer3d._objectState) {
|
||||||
|
if (!layer3d._showView || layer3d._showView == 2) {
|
||||||
|
layer2d.show = true
|
||||||
|
}
|
||||||
|
if (layer3d._showView == 3) {
|
||||||
|
layer2d.show = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
layer2d.show = state
|
layer2d.show = state
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function syncPrimitives(primitive) {
|
async function syncPrimitives(primitive) {
|
||||||
if (!sdk3D) {
|
if (!sdk3D) {
|
||||||
@ -535,6 +602,7 @@ function syncViewer() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get2DView() {
|
function get2DView() {
|
||||||
return sdk2D
|
return sdk2D
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,6 +123,7 @@ async function ScreenShotHD(sdk, options = {}, cd = () => { }) {
|
|||||||
startScreenShotObject.desist()
|
startScreenShotObject.desist()
|
||||||
startScreenShotObject = null
|
startScreenShotObject = null
|
||||||
}
|
}
|
||||||
|
window.removeEventListener('resize', resize)
|
||||||
_DialogObject = undefined
|
_DialogObject = undefined
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -133,7 +134,7 @@ async function ScreenShotHD(sdk, options = {}, cd = () => { }) {
|
|||||||
<div class="div-item">
|
<div class="div-item">
|
||||||
<div class="row text" style="align-items: flex-start;">
|
<div class="row text" style="align-items: flex-start;">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<span>当前窗口长宽:<span class="input-width">${sdk.viewer.canvas.width}</span>*<span class="input-height">${sdk.viewer.canvas.height}</span>像素</span>
|
<span>当前窗口长宽:<span class="input-width canvas-width-span">${sdk.viewer.canvas.width}</span>*<span class="input-height canvas-height-span">${sdk.viewer.canvas.height}</span>像素</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row scale-box" style="align-items: flex-start;">
|
<div class="row scale-box" style="align-items: flex-start;">
|
||||||
@ -176,6 +177,17 @@ async function ScreenShotHD(sdk, options = {}, cd = () => { }) {
|
|||||||
sdk.viewer.scene.screenSpaceCameraController.enableLook = false;
|
sdk.viewer.scene.screenSpaceCameraController.enableLook = false;
|
||||||
sdk.viewer._element.getElementsByClassName('compass')[0].style.pointerEvents = 'none'
|
sdk.viewer._element.getElementsByClassName('compass')[0].style.pointerEvents = 'none'
|
||||||
|
|
||||||
|
window.addEventListener('resize', resize);
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
setTimeout(() => {
|
||||||
|
contentElm.getElementsByClassName('canvas-width-span')[0].innerHTML = sdk.viewer.canvas.width
|
||||||
|
contentElm.getElementsByClassName('canvas-height-span')[0].innerHTML = sdk.viewer.canvas.height
|
||||||
|
contentElm.getElementsByClassName('output-width')[0].innerHTML = sdk.viewer.canvas.width * scale
|
||||||
|
contentElm.getElementsByClassName('output-height')[0].innerHTML = sdk.viewer.canvas.height * scale
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let centerResult = sdk.viewer.camera.pickEllipsoid(
|
let centerResult = sdk.viewer.camera.pickEllipsoid(
|
||||||
new Cesium.Cartesian2(
|
new Cesium.Cartesian2(
|
||||||
|
|||||||
@ -166,6 +166,9 @@ function open(sdk) {
|
|||||||
}
|
}
|
||||||
let isChanged = false
|
let isChanged = false
|
||||||
let rectangle = getViewExtend();
|
let rectangle = getViewExtend();
|
||||||
|
if(!rectangle) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let minLng = Cesium.Math.toDegrees(rectangle.west)
|
let minLng = Cesium.Math.toDegrees(rectangle.west)
|
||||||
let minLat = Cesium.Math.toDegrees(rectangle.south)
|
let minLat = Cesium.Math.toDegrees(rectangle.south)
|
||||||
|
|||||||
@ -102,11 +102,20 @@ function off() {
|
|||||||
let leftCanvas = leftBox.getElementsByTagName('canvas')[0]
|
let leftCanvas = leftBox.getElementsByTagName('canvas')[0]
|
||||||
leftBox.style.width = '100%'
|
leftBox.style.width = '100%'
|
||||||
leftCanvas.style.width = '100%'
|
leftCanvas.style.width = '100%'
|
||||||
|
let billboardAttributeBoxs = sdkP.viewer._element.getElementsByClassName('billboard-attribute-box')
|
||||||
|
for (let i = 0; i < billboardAttributeBoxs.length; i++) {
|
||||||
|
billboardAttributeBoxs[i].style.display = 'block'
|
||||||
|
}
|
||||||
sdkP = null
|
sdkP = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function init(sdk) {
|
async function init(sdk) {
|
||||||
|
let billboardAttributeBoxs = sdk.viewer._element.getElementsByClassName('billboard-attribute-box')
|
||||||
|
for (let i = 0; i < billboardAttributeBoxs.length; i++) {
|
||||||
|
billboardAttributeBoxs[i].style.display = 'none'
|
||||||
|
}
|
||||||
|
|
||||||
sdk.entityMap.forEach((item, key) => {
|
sdk.entityMap.forEach((item, key) => {
|
||||||
if (item.type && item.type == 'TrajectoryMotion' && item.viewFollow) {
|
if (item.type && item.type == 'TrajectoryMotion' && item.viewFollow) {
|
||||||
item.viewFollow = false
|
item.viewFollow = false
|
||||||
@ -137,10 +146,8 @@ async function init(sdk) {
|
|||||||
rightElm.style.position = 'absolute'
|
rightElm.style.position = 'absolute'
|
||||||
rightElm.style.right = 'calc(50% - 50px)'
|
rightElm.style.right = 'calc(50% - 50px)'
|
||||||
|
|
||||||
if (!activeIds || activeIds.length == 0) {
|
|
||||||
leftElm.style.display = 'none'
|
leftElm.style.display = 'none'
|
||||||
rightElm.style.display = 'none'
|
rightElm.style.display = 'none'
|
||||||
}
|
|
||||||
|
|
||||||
sdk.viewer._element.appendChild(leftElm)
|
sdk.viewer._element.appendChild(leftElm)
|
||||||
sdk.viewer._element.appendChild(rightElm)
|
sdk.viewer._element.appendChild(rightElm)
|
||||||
@ -149,6 +156,12 @@ async function init(sdk) {
|
|||||||
let right = 0
|
let right = 0
|
||||||
if (activeIds) {
|
if (activeIds) {
|
||||||
for (let i = 0; i < activeIds.length; i++) {
|
for (let i = 0; i < activeIds.length; i++) {
|
||||||
|
let thatP = sdk.entityMap.get(activeIds[i])
|
||||||
|
if (!thatP || (thatP.type === 'terrain' || !thatP.show) || thatP.type === 'TextBox') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
leftElm.style.display = 'unset'
|
||||||
|
rightElm.style.display = 'unset'
|
||||||
let status = statusMap.get(activeIds[i])
|
let status = statusMap.get(activeIds[i])
|
||||||
if (status) {
|
if (status) {
|
||||||
if (status.P) {
|
if (status.P) {
|
||||||
@ -278,7 +291,7 @@ async function init(sdk) {
|
|||||||
sdk.viewer.scene.preRender.addEventListener(syncViewer, syncObject)
|
sdk.viewer.scene.preRender.addEventListener(syncViewer, syncObject)
|
||||||
|
|
||||||
// sdk.viewer.imageryLayers.layerAdded.addEventListener(syncImageryLayerAdded);
|
// sdk.viewer.imageryLayers.layerAdded.addEventListener(syncImageryLayerAdded);
|
||||||
// sdk.viewer.imageryLayers.layerMoved.addEventListener(syncImageryLayerMoved);
|
sdk.viewer.imageryLayers.layerMoved.addEventListener(syncImageryLayerMoved);
|
||||||
// sdk.viewer.imageryLayers.layerRemoved.addEventListener(syncImageryLayerRemoved);
|
// sdk.viewer.imageryLayers.layerRemoved.addEventListener(syncImageryLayerRemoved);
|
||||||
// sdk.viewer.imageryLayers.layerShownOrHidden.addEventListener(syncImageryLayerShownOrHidden);
|
// sdk.viewer.imageryLayers.layerShownOrHidden.addEventListener(syncImageryLayerShownOrHidden);
|
||||||
|
|
||||||
@ -517,7 +530,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) {
|
|||||||
thatD.textShow = thatP.textShow
|
thatD.textShow = thatP.textShow
|
||||||
}
|
}
|
||||||
if (thatP.label && thatP.labelShow) {
|
if (thatP.label && thatP.labelShow) {
|
||||||
thatP.label.entity.show = true
|
thatP.labelShow = true
|
||||||
}
|
}
|
||||||
if (thatD.label) {
|
if (thatD.label) {
|
||||||
thatD.label.options.ground = false
|
thatD.label.options.ground = false
|
||||||
@ -711,6 +724,9 @@ async function setSplitDirection(v, id, isoff = false, entityId) {
|
|||||||
status.P = true
|
status.P = true
|
||||||
status.D = true
|
status.D = true
|
||||||
options.show = true
|
options.show = true
|
||||||
|
if(thatP.type==='layer') {
|
||||||
|
options.layer_index = thatP.layer_index
|
||||||
|
}
|
||||||
target = await new thatP.constructor(sdkD, options)
|
target = await new thatP.constructor(sdkD, options)
|
||||||
if (thatP.onClick) {
|
if (thatP.onClick) {
|
||||||
target.onClick = thatP.onClick
|
target.onClick = thatP.onClick
|
||||||
@ -794,6 +810,9 @@ async function setSplitDirection(v, id, isoff = false, entityId) {
|
|||||||
status.P = false
|
status.P = false
|
||||||
status.D = true
|
status.D = true
|
||||||
options.show = true
|
options.show = true
|
||||||
|
if(thatP.type==='layer') {
|
||||||
|
options.layer_index = thatP.layer_index
|
||||||
|
}
|
||||||
target = await new thatP.constructor(sdkD, options)
|
target = await new thatP.constructor(sdkD, options)
|
||||||
if (thatP.onClick) {
|
if (thatP.onClick) {
|
||||||
target.onClick = thatP.onClick
|
target.onClick = thatP.onClick
|
||||||
@ -905,7 +924,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) {
|
|||||||
}
|
}
|
||||||
if (thatP.type === 'GroundSvg' && thatP.text) {
|
if (thatP.type === 'GroundSvg' && thatP.text) {
|
||||||
thatP.text.show = thatP.textShow
|
thatP.text.show = thatP.textShow
|
||||||
target.textShow = false
|
target && (target.textShow = false)
|
||||||
}
|
}
|
||||||
if (thatP.label && thatP.labelShow) {
|
if (thatP.label && thatP.labelShow) {
|
||||||
thatP.label.entity.show = true
|
thatP.label.entity.show = true
|
||||||
@ -1033,7 +1052,13 @@ function syncImageryLayerAdded(layer, index) {
|
|||||||
sdkD.viewer.imageryLayers.addImageryProvider(layer.imageryProvider, index)
|
sdkD.viewer.imageryLayers.addImageryProvider(layer.imageryProvider, index)
|
||||||
}
|
}
|
||||||
function syncImageryLayerMoved(layer, newindxe, oldindex) {
|
function syncImageryLayerMoved(layer, newindxe, oldindex) {
|
||||||
let layerD = sdkD.viewer.imageryLayers._layers[oldindex]
|
let layerD
|
||||||
|
for (let i = 0; i < sdkD.viewer.imageryLayers._layers.length; i++) {
|
||||||
|
if (sdkD.viewer.imageryLayers._layers[i]._id === layer._id) {
|
||||||
|
layerD = sdkD.viewer.imageryLayers._layers[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!layerD) {
|
if (!layerD) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1042,13 +1067,15 @@ function syncImageryLayerMoved(layer, newindxe, oldindex) {
|
|||||||
sdkD.viewer.imageryLayers.lowerToBottom(layerD)
|
sdkD.viewer.imageryLayers.lowerToBottom(layerD)
|
||||||
}
|
}
|
||||||
// 移到最高层
|
// 移到最高层
|
||||||
else if (newindxe === sdk.viewer.imageryLayers._layers.length - 1) {
|
else if (newindxe === sdkD.viewer.imageryLayers._layers.length - 1) {
|
||||||
sdkD.viewer.imageryLayers.raiseToTop(layerD)
|
sdkD.viewer.imageryLayers.raiseToTop(layerD)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (newindxe < oldindex) {
|
if (newindxe < oldindex) {
|
||||||
|
if(newindxe<sdkD.viewer.imageryLayers._layers.length-1) {
|
||||||
sdkD.viewer.imageryLayers.lower(layerD)
|
sdkD.viewer.imageryLayers.lower(layerD)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
sdkD.viewer.imageryLayers.raise(layerD)
|
sdkD.viewer.imageryLayers.raise(layerD)
|
||||||
}
|
}
|
||||||
@ -1267,6 +1294,8 @@ function setActiveId(ids = []) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (leftElm && rightElm) {
|
if (leftElm && rightElm) {
|
||||||
|
leftElm.style.display = 'none'
|
||||||
|
rightElm.style.display = 'none'
|
||||||
let left = 0
|
let left = 0
|
||||||
let right = 0
|
let right = 0
|
||||||
for (let i = 0; i < activeIds.length; i++) {
|
for (let i = 0; i < activeIds.length; i++) {
|
||||||
@ -1284,10 +1313,8 @@ function setActiveId(ids = []) {
|
|||||||
|
|
||||||
|
|
||||||
let thatP = sdkP.entityMap.get(activeIds[i])
|
let thatP = sdkP.entityMap.get(activeIds[i])
|
||||||
let thatD = sdkD.entityMap.get(activeIds[i])
|
// let thatD = sdkD.entityMap.get(activeIds[i])
|
||||||
if (!thatP || (thatP.type === 'terrain' || !thatP.show)) {
|
if (!thatP || (thatP.type === 'terrain' || !thatP.show) || thatP.type === 'TextBox') {
|
||||||
leftElm.style.display = 'none'
|
|
||||||
rightElm.style.display = 'none'
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
leftElm.style.display = 'unset'
|
leftElm.style.display = 'unset'
|
||||||
|
|||||||
@ -1,45 +1,89 @@
|
|||||||
class eventBinding {
|
class EventBinding {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.element = {}
|
this.element = {}
|
||||||
}
|
}
|
||||||
static event = {}
|
static event = {}
|
||||||
|
|
||||||
getEvent(name) {
|
getEvent(name) {
|
||||||
return eventBinding.event[name]
|
return EventBinding.event[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
getEventAll() {
|
getEventAll() {
|
||||||
return eventBinding.event
|
return EventBinding.event
|
||||||
}
|
}
|
||||||
|
|
||||||
setEvent(name, event) {
|
setEvent(name, event) {
|
||||||
eventBinding.event[name] = event
|
EventBinding.event[name] = event
|
||||||
}
|
}
|
||||||
|
|
||||||
on(that, elements) {
|
on(that, elements) {
|
||||||
|
this.element = {}
|
||||||
for (let i = 0; i < elements.length; i++) {
|
for (let i = 0; i < elements.length; i++) {
|
||||||
let Event = []
|
|
||||||
let isEvent = false
|
|
||||||
let removeName = []
|
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let Event = {
|
||||||
|
'input': [],
|
||||||
|
'change': [],
|
||||||
|
'blur': [],
|
||||||
|
'click': []
|
||||||
|
}
|
||||||
|
let isEvent = false
|
||||||
|
let removeName = []
|
||||||
for (let m of elements[i].attributes) {
|
for (let m of elements[i].attributes) {
|
||||||
switch (m.name) {
|
switch (m.name) {
|
||||||
case '@model': {
|
case '@model': {
|
||||||
isEvent = true
|
isEvent = true
|
||||||
if (elements[i].type == 'checkbox') {
|
if (elements[i].type == 'checkbox') {
|
||||||
Event.push((e) => { that[m.value] = e.target.checked })
|
Event.change.push((e) => { that[m.value] = e.target.checked })
|
||||||
elements[i].checked = that[m.value]
|
elements[i].checked = that[m.value]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Event.push((e) => {
|
if (elements[i].type == 'number') {
|
||||||
|
Event.input.push((e) => {
|
||||||
|
if (e.target.value || e.target.value === 0) {
|
||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
if (e.target.type == 'number') {
|
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
|
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
||||||
|
if (((!e.target.max) && (!e.target.min)) || ((value <= Number(e.target.max)) && value >= Number(e.target.min))) {
|
||||||
|
// that[m.value] = value
|
||||||
|
value = value
|
||||||
|
}
|
||||||
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
// if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
// value = Number(e.target.dataset.min)
|
||||||
|
// }
|
||||||
|
that[m.value] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Event.blur.push((e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
|
||||||
|
value = Number(value)
|
||||||
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Event.input.push((e) => {
|
||||||
|
that[m.value] = e.target.value
|
||||||
|
})
|
||||||
|
}
|
||||||
if (elements[i].nodeName == 'IMG') {
|
if (elements[i].nodeName == 'IMG') {
|
||||||
elements[i].src = that[m.value]
|
elements[i].src = that[m.value]
|
||||||
}
|
}
|
||||||
@ -57,13 +101,13 @@ class eventBinding {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '@click': {
|
case '@click': {
|
||||||
elements[i].addEventListener('click', (e) => {
|
isEvent = true
|
||||||
if (typeof (that.Dialog[m.value]) === 'function') {
|
Event.click.push((e) => {
|
||||||
that.Dialog[m.value](e)
|
if (typeof (that[m.value]) === 'function') {
|
||||||
|
that[m.value](e)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
removeName.push(m.name)
|
removeName.push(m.name)
|
||||||
// elements[i].attributes.removeNamedItem(m.name)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,19 +118,18 @@ class eventBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isEvent) {
|
if (isEvent) {
|
||||||
let ventType = 'input'
|
for (let key in Event) {
|
||||||
if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') {
|
if (Event[key].length > 0) {
|
||||||
ventType = 'change'
|
elements[i].addEventListener(key, (e) => {
|
||||||
}
|
for (let t = 0; t < Event[key].length; t++) {
|
||||||
elements[i].addEventListener(ventType, (e) => {
|
Event[key][t](e)
|
||||||
for (let t = 0; t < Event.length; t++) {
|
|
||||||
Event[t](e)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const EventBinding = new eventBinding();
|
|
||||||
export default EventBinding;
|
export default EventBinding;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import Dialog from '../../../Obj/Element/Dialog';
|
import Dialog from '../../../Obj/Element/Dialog';
|
||||||
import { html } from "./_element";
|
import { html } from "./_element";
|
||||||
import EventBinding from '../../../Obj/Element/Dialog/eventBinding';
|
import EventBinding from './eventBinding';
|
||||||
import { syncData } from '../../MultiViewportMode'
|
import { syncData } from '../../MultiViewportMode'
|
||||||
import Tools from '../../../Tools'
|
import Tools from '../../../Tools'
|
||||||
import TimeLine from './TimeLine'
|
import TimeLine from './TimeLine'
|
||||||
@ -52,6 +52,14 @@ export default class Sunshine {
|
|||||||
that.viewer.clock.currentTime = Cesium.JulianDate.fromDate(now);
|
that.viewer.clock.currentTime = Cesium.JulianDate.fromDate(now);
|
||||||
that.viewer.clock.multiplier = that.options.speed;
|
that.viewer.clock.multiplier = that.options.speed;
|
||||||
that.viewer.shadowMap.softShadows = that.options.softShadow;
|
that.viewer.shadowMap.softShadows = that.options.softShadow;
|
||||||
|
that.viewer.shadowMap.cascadesEnabled = true
|
||||||
|
that.viewer.shadowMap.size = 2048;
|
||||||
|
that.viewer.shadowMap.numberOfCascades = 4; // 增加级联层数(默认3层)
|
||||||
|
that.viewer.shadowMap.maximumDistance = 5000; // 扩大阴影渲染距离
|
||||||
|
const lightCamera = that.viewer.shadowMap._lightCamera;
|
||||||
|
lightCamera.frustum.near = 0.1; // 缩小近平面距离
|
||||||
|
lightCamera.frustum.far = 10000; // 扩大远平面距离
|
||||||
|
that.viewer.shadowMap.normalOffset = true; // 避免深度冲突导致的阴影闪烁
|
||||||
|
|
||||||
that.edit(true)
|
that.edit(true)
|
||||||
}
|
}
|
||||||
@ -61,6 +69,10 @@ export default class Sunshine {
|
|||||||
set darkness(v) {
|
set darkness(v) {
|
||||||
this.options.darkness = v
|
this.options.darkness = v
|
||||||
this.viewer.shadowMap.darkness = 1.0 - this.options.darkness
|
this.viewer.shadowMap.darkness = 1.0 - this.options.darkness
|
||||||
|
this._elms.darkness &&
|
||||||
|
this._elms.darkness.forEach(item => {
|
||||||
|
item.value = v
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get speed() {
|
get speed() {
|
||||||
@ -68,6 +80,10 @@ export default class Sunshine {
|
|||||||
}
|
}
|
||||||
set speed(v) {
|
set speed(v) {
|
||||||
this.options.speed = v
|
this.options.speed = v
|
||||||
|
this._elms.speed &&
|
||||||
|
this._elms.speed.forEach(item => {
|
||||||
|
item.value = v
|
||||||
|
})
|
||||||
this.viewer.clock.multiplier = this.options.speed;
|
this.viewer.clock.multiplier = this.options.speed;
|
||||||
this.timeLine.setSpeed(v)
|
this.timeLine.setSpeed(v)
|
||||||
}
|
}
|
||||||
@ -98,15 +114,17 @@ export default class Sunshine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
|
let _this = this
|
||||||
this._DialogObject = await new Dialog(this.sdk, this.originalOptions, {
|
this._DialogObject = await new Dialog(this.sdk, this.originalOptions, {
|
||||||
title: '光照属性', left: '180px', top: '100px',
|
title: '光照属性', left: '180px', top: '100px',
|
||||||
confirmCallBack: (options) => {
|
// confirmCallBack: (options) => {
|
||||||
this.originalOptions = tools.deepCopyObj(this.options)
|
// this.originalOptions = tools.deepCopyObj(this.options)
|
||||||
this._DialogObject.close()
|
// this._DialogObject.close()
|
||||||
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
// 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)
|
// syncSplitData(this.sdk, this.options.id)
|
||||||
},
|
// this.remove()
|
||||||
|
// },
|
||||||
resetCallBack: () => {
|
resetCallBack: () => {
|
||||||
this.reset()
|
this.reset()
|
||||||
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
||||||
@ -116,6 +134,7 @@ export default class Sunshine {
|
|||||||
// },
|
// },
|
||||||
closeCallBack: () => {
|
closeCallBack: () => {
|
||||||
this.reset()
|
this.reset()
|
||||||
|
_this.remove()
|
||||||
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
||||||
// color: "color('rgba(255,255,255," + this.newData.transparency + ")')",
|
// color: "color('rgba(255,255,255," + this.newData.transparency + ")')",
|
||||||
// show: true,
|
// show: true,
|
||||||
@ -211,6 +230,12 @@ export default class Sunshine {
|
|||||||
this.entity = null
|
this.entity = null
|
||||||
this.timeLine.clear()
|
this.timeLine.clear()
|
||||||
|
|
||||||
|
this.viewer.shadowMap.cascadesEnabled = false
|
||||||
|
this.viewer.shadowMap.size = 1024;
|
||||||
|
this.viewer.shadowMap.numberOfCascades = 3; // 增加级联层数(默认3层)
|
||||||
|
const lightCamera = this.viewer.shadowMap._lightCamera;
|
||||||
|
this.viewer.shadowMap.normalOffset = false; // 避免深度冲突导致的阴影闪烁
|
||||||
|
|
||||||
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this._DialogObject = null
|
this._DialogObject = null
|
||||||
|
|||||||
@ -3,12 +3,13 @@ export default class TimeLine {
|
|||||||
this.sdk = { ...sdk };
|
this.sdk = { ...sdk };
|
||||||
this.progress = document.getElementById('progress');
|
this.progress = document.getElementById('progress');
|
||||||
this.handle = document.getElementById('handle');
|
this.handle = document.getElementById('handle');
|
||||||
this.timeline = document.getElementById('timeline');
|
// this.timeline = document.getElementById('timeline');
|
||||||
|
this.timeline = document.getElementsByClassName('timeline-container')[0];
|
||||||
this.currentTime = document.getElementById('currentTime');
|
this.currentTime = document.getElementById('currentTime');
|
||||||
this.timelineCon = document.getElementsByClassName('timeline-container')[0];
|
this.timelineCon = document.getElementsByClassName('timeline-container')[0];
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
this.animationId;
|
this.animationId;
|
||||||
this.startTime = Date.now();
|
this.startTime = performance.now();
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
this.pauseed = false;
|
this.pauseed = false;
|
||||||
@ -27,12 +28,12 @@ export default class TimeLine {
|
|||||||
document.getElementsByClassName('time-marks')[0].appendChild(label)
|
document.getElementsByClassName('time-marks')[0].appendChild(label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
that.startTime = performance.now() - ((that.manualPosition || 0) * 86400 * 1000 / that.speed);
|
||||||
|
|
||||||
that.startTime = Date.now() - ((that.manualPosition || 0) * 86400 * 1000 / that.speed);
|
|
||||||
|
|
||||||
that.timeline.addEventListener('mousedown', (e) => {
|
that.timeline.addEventListener('mousedown', (e) => {
|
||||||
|
if (e.srcElement.className === 'handle') {
|
||||||
that.isDragging = true;
|
that.isDragging = true;
|
||||||
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,17 +54,26 @@ export default class TimeLine {
|
|||||||
|
|
||||||
document.getElementById('timePause').addEventListener('click', function () {
|
document.getElementById('timePause').addEventListener('click', function () {
|
||||||
that.pauseed = !that.pauseed;
|
that.pauseed = !that.pauseed;
|
||||||
if (that.pauseed) {
|
if (that.pauseed) {//暂停
|
||||||
|
that.pausedTime = performance.now(); // 记录暂停时刻
|
||||||
document.getElementById('timePause').textContent = '播放';
|
document.getElementById('timePause').textContent = '播放';
|
||||||
that.animationId && cancelAnimationFrame(that.animationId);
|
that.animationId && cancelAnimationFrame(that.animationId);
|
||||||
that.pausedTime = Date.now(); // 记录暂停时刻
|
|
||||||
that.sdk.viewer.clock.shouldAnimate = false
|
that.sdk.viewer.clock.shouldAnimate = false
|
||||||
} else {
|
} else {//播放
|
||||||
|
let now = performance.now()
|
||||||
|
const pausedDuration = now - that.pausedTime;
|
||||||
document.getElementById('timePause').textContent = '暂停';
|
document.getElementById('timePause').textContent = '暂停';
|
||||||
that.manualPosition = null
|
that.manualPosition = null
|
||||||
|
|
||||||
const pausedDuration = Date.now() - that.pausedTime;
|
|
||||||
that.startTime += pausedDuration; // 补偿暂停期间的时间差
|
that.startTime += pausedDuration; // 补偿暂停期间的时间差
|
||||||
|
|
||||||
|
if (that.changeDate) {//切换日期后让时间从0开始
|
||||||
|
if (that.changeDateGrag) {
|
||||||
|
that.changeDateGrag = undefined
|
||||||
|
} else {
|
||||||
|
that.startTime = now
|
||||||
|
}
|
||||||
|
that.changeDate = undefined
|
||||||
|
}
|
||||||
that.sdk.viewer.clock.shouldAnimate = true
|
that.sdk.viewer.clock.shouldAnimate = true
|
||||||
that.update(); // 重启动画循环
|
that.update(); // 重启动画循环
|
||||||
}
|
}
|
||||||
@ -71,22 +81,25 @@ export default class TimeLine {
|
|||||||
}
|
}
|
||||||
moveComplay(func) {
|
moveComplay(func) {
|
||||||
let that = this
|
let that = this
|
||||||
that.timeline.addEventListener('mouseup', () => {
|
// that.timeline.addEventListener('mouseup', () => {
|
||||||
|
document.addEventListener('mouseup', () => {
|
||||||
|
if (that.isDragging) {
|
||||||
that.isDragging = false;
|
that.isDragging = false;
|
||||||
if (that.manualPosition !== null) {
|
if (that.manualPosition !== null) {
|
||||||
// that.sdk.viewer.clock.shouldAnimate = true
|
// that.sdk.viewer.clock.shouldAnimate = true
|
||||||
that.startTime = Date.now() - (that.manualPosition * 86400 * 1000 / that.speed);
|
that.startTime = performance.now() - (that.manualPosition * 86400 * 1000 / that.speed);
|
||||||
that.manualPosition = null;
|
that.manualPosition = null;
|
||||||
|
that.changeDate && (that.changeDateGrag = true)
|
||||||
if (!that.pauseed) {
|
if (!that.pauseed) {
|
||||||
that.update()
|
that.update()
|
||||||
func(that.time)
|
func(that.time)
|
||||||
} else {
|
} else {
|
||||||
that.pausedTime = Date.now(); // 记录暂停时刻
|
that.pausedTime = performance.now(); // 记录暂停时刻
|
||||||
func(that.currentTime.textContent)
|
func(that.currentTime.textContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
formatTime(seconds) {
|
formatTime(seconds) {
|
||||||
@ -98,30 +111,55 @@ export default class TimeLine {
|
|||||||
|
|
||||||
update() {
|
update() {
|
||||||
if (this.manualPosition !== null) return;
|
if (this.manualPosition !== null) return;
|
||||||
|
if (this.changeDate) {//切换日期后让时间从0开始
|
||||||
const elapsed = (Date.now() - this.startTime) * this.speed;
|
this.startTime = performance.now()
|
||||||
const totalSeconds = elapsed / 1000;
|
}
|
||||||
const daySeconds = totalSeconds % 86400;
|
let elapsed = (performance.now() - this.startTime) * this.speed;
|
||||||
|
// if (this.elapsed) {
|
||||||
|
// elapsed = elapsed + this.elapsed
|
||||||
|
// this.elapsed = undefined
|
||||||
|
// }
|
||||||
|
const totalSeconds = elapsed / 1000;//秒
|
||||||
|
const daySeconds = totalSeconds % 86400;//天
|
||||||
const percentage = daySeconds / 86400;
|
const percentage = daySeconds / 86400;
|
||||||
|
|
||||||
this.progress.style.width = `${percentage * 100}%`;
|
this.progress.style.width = `${percentage * 100}%`;
|
||||||
this.time = this.formatTime(daySeconds)
|
this.time = this.formatTime(daySeconds)
|
||||||
this.currentTime.textContent = this.time;
|
this.currentTime.textContent = this.time;
|
||||||
|
if (!this.pauseed) {
|
||||||
|
this.animationId && cancelAnimationFrame(this.animationId);
|
||||||
this.animationId = requestAnimationFrame(this.update);
|
this.animationId = requestAnimationFrame(this.update);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setSpeed(v) {
|
setSpeed(v) {
|
||||||
|
let now = performance.now()
|
||||||
|
if (!this.pauseed) {
|
||||||
const currentProgress = this.manualPosition ??
|
const currentProgress = this.manualPosition ??
|
||||||
(Date.now() - this.startTime) * this.speed / (86400 * 1000);
|
(performance.now() - this.startTime) * this.speed / (86400 * 1000);
|
||||||
|
|
||||||
this.speed = v;
|
this.speed = v;
|
||||||
this.startTime = Date.now() - (currentProgress * 86400 * 1000 / this.speed);
|
this.startTime = performance.now() - (currentProgress * 86400 * 1000 / this.speed);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
let pausedDuration = now - this.pausedTime;
|
||||||
|
this.startTime += pausedDuration; // 补偿暂停期间的时间差
|
||||||
|
const currentProgress = this.manualPosition ??
|
||||||
|
(now - this.startTime) * this.speed / (86400 * 1000);
|
||||||
|
this.speed = v;
|
||||||
|
this.startTime = now - (currentProgress * 86400 * 1000 / this.speed);
|
||||||
|
|
||||||
|
this.pausedTime = now; // 记录切换speed暂停时刻
|
||||||
|
// this.speed = v;
|
||||||
|
}
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
this.update();
|
|
||||||
|
// this.update();
|
||||||
|
|
||||||
}
|
}
|
||||||
updateTime() {
|
updateTime() {
|
||||||
this.startTime = Date.now() - (this.manualPosition * 86400 * 1000 / this.speed);
|
|
||||||
this.manualPosition = null;
|
this.manualPosition = null;
|
||||||
|
this.startTime = performance.now() - ((this.manualPosition || 0) * 86400 * 1000 / this.speed);
|
||||||
|
this.pauseed && (this.changeDate = true)
|
||||||
|
this.changeDateGrag = undefined
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { getTheme, setTheme } from "../Obj/Element/theme";
|
|||||||
import { setActiveViewer as setMultiViewportActiveViewer } from './MultiViewportMode'
|
import { setActiveViewer as setMultiViewportActiveViewer } from './MultiViewportMode'
|
||||||
import { setActiveViewer as setSplitActiveViewer, getSdk } from './SplitScreen'
|
import { setActiveViewer as setSplitActiveViewer, getSdk } from './SplitScreen'
|
||||||
import { updateCluster } from './cluster/cluster'
|
import { updateCluster } from './cluster/cluster'
|
||||||
|
import { getHost } from "../on";
|
||||||
|
|
||||||
let coordinateSystem = 'EPSG:4326'
|
let coordinateSystem = 'EPSG:4326'
|
||||||
let _cartesian
|
let _cartesian
|
||||||
@ -110,7 +111,7 @@ function CesiumContainer(sdk, options) {
|
|||||||
}
|
}
|
||||||
containerObject[sdk.viewer._element.className] || (containerObject[sdk.viewer._element.className] = {})
|
containerObject[sdk.viewer._element.className] || (containerObject[sdk.viewer._element.className] = {})
|
||||||
containerObject[sdk.viewer._element.className].event && containerObject[sdk.viewer._element.className].event.destroy()
|
containerObject[sdk.viewer._element.className].event && containerObject[sdk.viewer._element.className].event.destroy()
|
||||||
let tools = new Tools()
|
let tools = new Tools(sdk)
|
||||||
let element = sdk.viewer._element
|
let element = sdk.viewer._element
|
||||||
let proj = sdk.proj
|
let proj = sdk.proj
|
||||||
for (let key in options) {
|
for (let key in options) {
|
||||||
@ -173,15 +174,28 @@ function CesiumContainer(sdk, options) {
|
|||||||
}
|
}
|
||||||
let event = new MouseEvent(sdk)
|
let event = new MouseEvent(sdk)
|
||||||
containerObject[sdk.viewer._element.className].event = event
|
containerObject[sdk.viewer._element.className].event = event
|
||||||
|
let lastPickTime = 0;
|
||||||
|
let timeoutEvent
|
||||||
event.mouse_move((movement, cartesian) => {
|
event.mouse_move((movement, cartesian) => {
|
||||||
_cartesian = cartesian
|
_cartesian = cartesian
|
||||||
|
// const now = Date.now();
|
||||||
|
// if (now - lastPickTime < 500) {
|
||||||
|
// clearTimeout(timeoutEvent)
|
||||||
|
// timeoutEvent = setTimeout(() => {
|
||||||
|
// update()
|
||||||
|
// }, 500);
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// lastPickTime = now;
|
||||||
update()
|
update()
|
||||||
})
|
})
|
||||||
function update() {
|
async function update() {
|
||||||
if (!_cartesian) {
|
if (!_cartesian) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// let pos = sdk.viewer.scene.clampToHeight(_cartesian)
|
||||||
let position = tools.cartesian3Towgs84(_cartesian, sdk.viewer)
|
let position = tools.cartesian3Towgs84(_cartesian, sdk.viewer)
|
||||||
|
// position.alt = height
|
||||||
if (coordinateSystem === 'EPSG:4326') {
|
if (coordinateSystem === 'EPSG:4326') {
|
||||||
infoElm.innerHTML = `
|
infoElm.innerHTML = `
|
||||||
<span>经度:</span><span>${Number(position.lng.toFixed(6))}° </span>
|
<span>经度:</span><span>${Number(position.lng.toFixed(6))}° </span>
|
||||||
@ -244,6 +258,16 @@ function setBillboardDefaultUrl(url, name) {
|
|||||||
else {
|
else {
|
||||||
name = 'billboard_default_url'
|
name = 'billboard_default_url'
|
||||||
}
|
}
|
||||||
|
let host = getHost()
|
||||||
|
if (!url.startsWith("http")) {
|
||||||
|
//说明是本地的json,在磁盘中存在的
|
||||||
|
if (!url.includes(":")) {
|
||||||
|
if (host) {
|
||||||
|
let o = new URL(url, host)
|
||||||
|
url = o.href
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
localStorage.setItem(name, url);
|
localStorage.setItem(name, url);
|
||||||
}
|
}
|
||||||
/*获取广告牌默认图标*/
|
/*获取广告牌默认图标*/
|
||||||
|
|||||||
@ -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)
|
||||||
@ -173,6 +176,10 @@ function MouseRightMenu(sdk, status, callBack) {
|
|||||||
// that.edit(true)
|
// that.edit(true)
|
||||||
// this.attribute(entityId)
|
// this.attribute(entityId)
|
||||||
break
|
break
|
||||||
|
case '文本框':
|
||||||
|
object.position = position
|
||||||
|
key = 'textBox'
|
||||||
|
break
|
||||||
}
|
}
|
||||||
eventListener[sdk.div_id].callBack(key, object)
|
eventListener[sdk.div_id].callBack(key, object)
|
||||||
_element.removeChild(menuElm)
|
_element.removeChild(menuElm)
|
||||||
|
|||||||
@ -100,6 +100,7 @@ import MeasureAngle from '../Measure/MeasureAngle'
|
|||||||
import MeasureAzimuth from '../Measure/MeasureAzimuth'
|
import MeasureAzimuth from '../Measure/MeasureAzimuth'
|
||||||
import DrawPolyline from '../Draw/drawPolyline'
|
import DrawPolyline from '../Draw/drawPolyline'
|
||||||
import DrawPolygon from '../Draw/drawPolygon'
|
import DrawPolygon from '../Draw/drawPolygon'
|
||||||
|
import DrawThreeRect from '../Draw/drawThreeRect'
|
||||||
import DrawPoint from '../Draw/drawPoint'
|
import DrawPoint from '../Draw/drawPoint'
|
||||||
import DrawCircle from '../Draw/drawCircle'
|
import DrawCircle from '../Draw/drawCircle'
|
||||||
import DrawElliptic from '../Draw/drawElliptic'
|
import DrawElliptic from '../Draw/drawElliptic'
|
||||||
@ -157,7 +158,7 @@ import WaterSurface from '../Obj/Base/WaterSurface'
|
|||||||
// import ItineraryMove from '../Obj/Base/ItineraryMove'
|
// import ItineraryMove from '../Obj/Base/ItineraryMove'
|
||||||
import TrajectoryMotion from '../Obj/Base/TrajectoryMotion'
|
import TrajectoryMotion from '../Obj/Base/TrajectoryMotion'
|
||||||
import TrajectoryMotionObject from '../Obj/Base/TrajectoryMotionObject'
|
import TrajectoryMotionObject from '../Obj/Base/TrajectoryMotionObject'
|
||||||
import Road from '../Obj/Base/Road'
|
// import Road from '../Obj/Base/Road'
|
||||||
import Graffiti from '../Obj/Base/Graffiti'
|
import Graffiti from '../Obj/Base/Graffiti'
|
||||||
import GroundImage from '../Obj/Base/GroundImage'
|
import GroundImage from '../Obj/Base/GroundImage'
|
||||||
import GroundSvg from '../Obj/Base/GroundSvg'
|
import GroundSvg from '../Obj/Base/GroundSvg'
|
||||||
@ -185,6 +186,9 @@ import Frustum from '../Obj/AirLine/frustum'
|
|||||||
import DrawTakeOff from '../Obj/AirLine/DrawTakeOff'
|
import DrawTakeOff from '../Obj/AirLine/DrawTakeOff'
|
||||||
import FlowLine from '../Obj/Base/FlowLine'
|
import FlowLine from '../Obj/Base/FlowLine'
|
||||||
import Sunshine from '../Global/efflect/Sunshine'
|
import Sunshine from '../Global/efflect/Sunshine'
|
||||||
|
import Road2 from '../Obj/Base/RoadObject'
|
||||||
|
import TextBox from '../Obj/Base/TextBox'
|
||||||
|
import BatchModel from '../Obj/Base/BatchModel'
|
||||||
|
|
||||||
const YJEarthismeasuring = Symbol('测量状态')
|
const YJEarthismeasuring = Symbol('测量状态')
|
||||||
const screenRecord = Symbol('录屏对象')
|
const screenRecord = Symbol('录屏对象')
|
||||||
@ -236,7 +240,7 @@ if (!window.YJ) {
|
|||||||
Model2,
|
Model2,
|
||||||
TrajectoryMotion,
|
TrajectoryMotion,
|
||||||
TrajectoryMotionObject,
|
TrajectoryMotionObject,
|
||||||
Road,
|
// Road,
|
||||||
Graffiti,
|
Graffiti,
|
||||||
GroundImage,
|
GroundImage,
|
||||||
GroundSvg,
|
GroundSvg,
|
||||||
@ -256,7 +260,10 @@ if (!window.YJ) {
|
|||||||
FRUSTUN: Frustum,
|
FRUSTUN: Frustum,
|
||||||
// GenerateRoute
|
// GenerateRoute
|
||||||
Dialog,
|
Dialog,
|
||||||
FlowLine
|
FlowLine,
|
||||||
|
Road2,
|
||||||
|
TextBox,
|
||||||
|
BatchModel
|
||||||
},
|
},
|
||||||
YJEarth,
|
YJEarth,
|
||||||
Tools,
|
Tools,
|
||||||
@ -374,6 +381,7 @@ if (!window.YJ) {
|
|||||||
DrawAssemble,
|
DrawAssemble,
|
||||||
DrawSector,
|
DrawSector,
|
||||||
DrawTakeOff,
|
DrawTakeOff,
|
||||||
|
DrawThreeRect
|
||||||
},
|
},
|
||||||
// 分析
|
// 分析
|
||||||
Analysis: {
|
Analysis: {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class MeasureDistance extends Measure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async computeDisByTowPoint(p1, p2) {
|
async computeDisByTowPoint(p1, p2) {
|
||||||
let d = this.computeDistance([p1, p2])
|
let d = this.computeDistance2([p1, p2])
|
||||||
let meters = 10
|
let meters = 10
|
||||||
let createLabel = (distance) => {
|
let createLabel = (distance) => {
|
||||||
if(this._isDestroy) {
|
if(this._isDestroy) {
|
||||||
@ -80,7 +80,7 @@ class MeasureDistance extends Measure {
|
|||||||
let l = arr.length - 1
|
let l = arr.length - 1
|
||||||
arr.forEach((item, index) => {
|
arr.forEach((item, index) => {
|
||||||
if (index !== l) {
|
if (index !== l) {
|
||||||
let d1 = this.computeDistance([item.position, arr[index + 1].position])
|
let d1 = this.computeDistance2([item.position, arr[index + 1].position])
|
||||||
let d2 = Math.abs(item.position.alt - arr[index + 1].position.alt)
|
let d2 = Math.abs(item.position.alt - arr[index + 1].position.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
total_length += d3
|
total_length += d3
|
||||||
@ -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}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class MeasureDistance extends Measure {
|
|||||||
let l = this.clampPositions.length - 1
|
let l = this.clampPositions.length - 1
|
||||||
this.clampPositions.forEach((item, index) => {
|
this.clampPositions.forEach((item, index) => {
|
||||||
if (index !== l) {
|
if (index !== l) {
|
||||||
let d1 = this.computeDistance([item.position, this.clampPositions[index + 1].position])
|
let d1 = this.computeDistance2([item.position, this.clampPositions[index + 1].position])
|
||||||
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
total_length += d3
|
total_length += d3
|
||||||
@ -270,7 +270,7 @@ class MeasureDistance extends Measure {
|
|||||||
// if (this.cachePositions.length) {
|
// if (this.cachePositions.length) {
|
||||||
// let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
// let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
||||||
// let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
// let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
||||||
// let cur_len = this.computeDistance([cur_point, pre_p])
|
// let cur_len = this.computeDistance2([cur_point, pre_p])
|
||||||
// let text = "当前投影距离:" + cur_len + " 米"
|
// let text = "当前投影距离:" + cur_len + " 米"
|
||||||
// // this.tip.set_text(text)
|
// // this.tip.set_text(text)
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class MeasureDistance extends Measure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async computeDisByTowPoint(p1, p2) {
|
async computeDisByTowPoint(p1, p2) {
|
||||||
let d = this.computeDistance([p1, p2])
|
let d = this.computeDistance2([p1, p2])
|
||||||
let meters = 10
|
let meters = 10
|
||||||
let createLabel = (distance) => {
|
let createLabel = (distance) => {
|
||||||
let label = this.getLabel("贴地距离:" + distance.toFixed(2) + "米")
|
let label = this.getLabel("贴地距离:" + distance.toFixed(2) + "米")
|
||||||
@ -84,7 +84,7 @@ class MeasureDistance extends Measure {
|
|||||||
let l = arr.length - 1
|
let l = arr.length - 1
|
||||||
arr.forEach((item, index) => {
|
arr.forEach((item, index) => {
|
||||||
if (index !== l) {
|
if (index !== l) {
|
||||||
let d1 = this.computeDistance([item.position, arr[index + 1].position])
|
let d1 = this.computeDistance2([item.position, arr[index + 1].position])
|
||||||
let d2 = Math.abs(item.position.alt - arr[index + 1].position.alt)
|
let d2 = Math.abs(item.position.alt - arr[index + 1].position.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
total_length += d3
|
total_length += d3
|
||||||
@ -135,7 +135,7 @@ class MeasureDistance extends Measure {
|
|||||||
let l = this.clampPositions.length - 1
|
let l = this.clampPositions.length - 1
|
||||||
this.clampPositions.forEach((item, index) => {
|
this.clampPositions.forEach((item, index) => {
|
||||||
if (index !== l) {
|
if (index !== l) {
|
||||||
let d1 = this.computeDistance([item.position, this.clampPositions[index + 1].position])
|
let d1 = this.computeDistance2([item.position, this.clampPositions[index + 1].position])
|
||||||
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
total_length += d3
|
total_length += d3
|
||||||
@ -231,7 +231,7 @@ class MeasureDistance extends Measure {
|
|||||||
if (this.ids.length !== 0) {
|
if (this.ids.length !== 0) {
|
||||||
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
||||||
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
||||||
let cur_len = this.computeDistance([cur_point, pre_p])
|
let cur_len = this.computeDistance2([cur_point, pre_p])
|
||||||
let text = "投影距离:" + cur_len + " 米"
|
let text = "投影距离:" + cur_len + " 米"
|
||||||
this.ids.push(MeasureDistance.create_point(car, {label: this.getLabel(text)}, this))
|
this.ids.push(MeasureDistance.create_point(car, {label: this.getLabel(text)}, this))
|
||||||
this.cachePositions.push(car)
|
this.cachePositions.push(car)
|
||||||
@ -250,7 +250,7 @@ class MeasureDistance extends Measure {
|
|||||||
if (this.cachePositions.length) {
|
if (this.cachePositions.length) {
|
||||||
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
||||||
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
||||||
let cur_len = this.computeDistance([cur_point, pre_p])
|
let cur_len = this.computeDistance2([cur_point, pre_p])
|
||||||
let text = "当前投影距离:" + cur_len + " 米"
|
let text = "当前投影距离:" + cur_len + " 米"
|
||||||
this.tip.set_text(text)
|
this.tip.set_text(text)
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ class MeasureDistance extends Measure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeAngle(start, end) {
|
computeAngle(start, end) {
|
||||||
let d1 = this.computeDistance([start, end])
|
let d1 = this.computeDistance2([start, end])
|
||||||
let d2 = Math.abs(start.alt - end.alt)
|
let d2 = Math.abs(start.alt - end.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
let cosAlpha = d1 / d3
|
let cosAlpha = d1 / d3
|
||||||
|
|||||||
@ -128,7 +128,7 @@ class MeasureHeight extends Measure {
|
|||||||
this.positions[1] = Cesium.Cartesian3.fromDegrees(this.firstpoint.lng, this.firstpoint.lat, cur_point.alt)
|
this.positions[1] = Cesium.Cartesian3.fromDegrees(this.firstpoint.lng, this.firstpoint.lat, cur_point.alt)
|
||||||
this.positions[2] = cartesian
|
this.positions[2] = cartesian
|
||||||
this.position = this.positions[1]
|
this.position = this.positions[1]
|
||||||
this.circleRadius = this.computeDistance([this.firstpoint, cur_point])
|
this.circleRadius = this.computeDistance2([this.firstpoint, cur_point])
|
||||||
this.height = Number((cur_point.alt - this.firstpoint.alt).toFixed(2))
|
this.height = Number((cur_point.alt - this.firstpoint.alt).toFixed(2))
|
||||||
this.text = "相对高度:" + this.height + " 米"
|
this.text = "相对高度:" + this.height + " 米"
|
||||||
this.tip.set_text("左键完成,右键取消;半径:" + this.circleRadius + " 米")
|
this.tip.set_text("左键完成,右键取消;半径:" + this.circleRadius + " 米")
|
||||||
@ -145,7 +145,7 @@ class MeasureHeight extends Measure {
|
|||||||
this.positions[1] = Cesium.Cartesian3.fromDegrees(this.firstpoint.lng, this.firstpoint.lat, cur_point.alt)
|
this.positions[1] = Cesium.Cartesian3.fromDegrees(this.firstpoint.lng, this.firstpoint.lat, cur_point.alt)
|
||||||
this.positions[2] = cartesian
|
this.positions[2] = cartesian
|
||||||
this.position = this.positions[1]
|
this.position = this.positions[1]
|
||||||
this.circleRadius = this.computeDistance([this.firstpoint, cur_point])
|
this.circleRadius = this.computeDistance2([this.firstpoint, cur_point])
|
||||||
this.height = Number((cur_point.alt - this.firstpoint.alt).toFixed(2))
|
this.height = Number((cur_point.alt - this.firstpoint.alt).toFixed(2))
|
||||||
this.text = "相对高度:" + this.height + " 米"
|
this.text = "相对高度:" + this.height + " 米"
|
||||||
this.tip.set_text("左键完成,右键取消;半径:" + this.circleRadius + " 米")
|
this.tip.set_text("左键完成,右键取消;半径:" + this.circleRadius + " 米")
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class MeasureProjectionDistance extends Measure {
|
|||||||
let l = this.clampPositions.length - 1
|
let l = this.clampPositions.length - 1
|
||||||
this.clampPositions.forEach((item, index) => {
|
this.clampPositions.forEach((item, index) => {
|
||||||
if (index !== l) {
|
if (index !== l) {
|
||||||
let d1 = this.computeDistance([item.position, this.clampPositions[index + 1].position])
|
let d1 = this.computeDistance2([item.position, this.clampPositions[index + 1].position])
|
||||||
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
total_length += d3
|
total_length += d3
|
||||||
@ -174,7 +174,7 @@ class MeasureProjectionDistance extends Measure {
|
|||||||
if (this.ids.length !== 0) {
|
if (this.ids.length !== 0) {
|
||||||
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
||||||
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
||||||
let cur_len = this.computeDistance([cur_point, pre_p])
|
let cur_len = this.computeDistance2([cur_point, pre_p])
|
||||||
let text = "投影距离:" + cur_len + " 米"
|
let text = "投影距离:" + cur_len + " 米"
|
||||||
this.ids.push(MeasureProjectionDistance.create_point(car, {label: this.getLabel(text)}, this))
|
this.ids.push(MeasureProjectionDistance.create_point(car, {label: this.getLabel(text)}, this))
|
||||||
this.cachePositions.push(car)
|
this.cachePositions.push(car)
|
||||||
@ -215,7 +215,7 @@ class MeasureProjectionDistance extends Measure {
|
|||||||
if (this.cachePositions.length) {
|
if (this.cachePositions.length) {
|
||||||
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
let cur_point = this.cartesian3Towgs84(car, this.viewer)
|
||||||
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
||||||
let cur_len = this.computeDistance([cur_point, pre_p])
|
let cur_len = this.computeDistance2([cur_point, pre_p])
|
||||||
let text = "当前投影距离:" + cur_len + " 米"
|
let text = "当前投影距离:" + cur_len + " 米"
|
||||||
this.tip.set_text(text)
|
this.tip.set_text(text)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class MeasureSlopeDistance extends Measure {
|
|||||||
let l = this.clampPositions.length - 1
|
let l = this.clampPositions.length - 1
|
||||||
this.clampPositions.forEach((item, index) => {
|
this.clampPositions.forEach((item, index) => {
|
||||||
if (index !== l) {
|
if (index !== l) {
|
||||||
let d1 = this.computeDistance([item.position, this.clampPositions[index + 1].position])
|
let d1 = this.computeDistance2([item.position, this.clampPositions[index + 1].position])
|
||||||
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
let d2 = Math.abs(item.position.alt - this.clampPositions[index + 1].position.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
total_length += d3
|
total_length += d3
|
||||||
@ -235,7 +235,7 @@ class MeasureSlopeDistance extends Measure {
|
|||||||
if (this.cachePositions.length) {
|
if (this.cachePositions.length) {
|
||||||
let cur_point = this.cartesian3Towgs84(cartesian, this.viewer)
|
let cur_point = this.cartesian3Towgs84(cartesian, this.viewer)
|
||||||
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
let pre_p = this.cartesian3Towgs84(this.cachePositions[this.cachePositions.length - 1], this.viewer)
|
||||||
let d1 = this.computeDistance([pre_p, cur_point])
|
let d1 = this.computeDistance2([pre_p, cur_point])
|
||||||
let d2 = Math.abs(pre_p.alt - cur_point.alt)
|
let d2 = Math.abs(pre_p.alt - cur_point.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
let cosAlpha = d1 / d3
|
let cosAlpha = d1 / d3
|
||||||
@ -276,7 +276,7 @@ class MeasureSlopeDistance extends Measure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeAngle(start, end) {
|
computeAngle(start, end) {
|
||||||
let d1 = this.computeDistance([start, end])
|
let d1 = this.computeDistance2([start, end])
|
||||||
let d2 = Math.abs(start.alt - end.alt)
|
let d2 = Math.abs(start.alt - end.alt)
|
||||||
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
let d3 = Math.sqrt(d1 * d1 + d2 * d2)
|
||||||
let cosAlpha = d1 / d3
|
let cosAlpha = d1 / d3
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class MeasureTriangle extends Measure {
|
|||||||
cal_distance(positions) {
|
cal_distance(positions) {
|
||||||
let p1 = this.cartesian3Towgs84(positions[0], this.viewer)
|
let p1 = this.cartesian3Towgs84(positions[0], this.viewer)
|
||||||
let p2 = this.cartesian3Towgs84(positions[1], this.viewer)
|
let p2 = this.cartesian3Towgs84(positions[1], this.viewer)
|
||||||
let dis = this.computeDistance([p1, p2])
|
let dis = this.computeDistance2([p1, p2])
|
||||||
p1.alt = p1.alt.toFixed(2)
|
p1.alt = p1.alt.toFixed(2)
|
||||||
p2.alt = p2.alt.toFixed(2)
|
p2.alt = p2.alt.toFixed(2)
|
||||||
if (p1.alt === p2.alt) {//水平边
|
if (p1.alt === p2.alt) {//水平边
|
||||||
@ -128,10 +128,10 @@ class MeasureTriangle extends Measure {
|
|||||||
let positions2 = this.id_map.get(id2).positions
|
let positions2 = this.id_map.get(id2).positions
|
||||||
let p1 = this.cartesian3Towgs84(positions1[0], this.viewer)
|
let p1 = this.cartesian3Towgs84(positions1[0], this.viewer)
|
||||||
let p2 = this.cartesian3Towgs84(positions1[1], this.viewer)
|
let p2 = this.cartesian3Towgs84(positions1[1], this.viewer)
|
||||||
let shuiping = this.computeDistance([p2, p1])
|
let shuiping = this.computeDistance2([p2, p1])
|
||||||
let p3 = this.cartesian3Towgs84(positions2[0], this.viewer)
|
let p3 = this.cartesian3Towgs84(positions2[0], this.viewer)
|
||||||
let p4 = this.cartesian3Towgs84(positions2[1], this.viewer)
|
let p4 = this.cartesian3Towgs84(positions2[1], this.viewer)
|
||||||
let d = this.computeDistance([p3, p4])
|
let d = this.computeDistance2([p3, p4])
|
||||||
let h = Math.abs(p3.alt - p4.alt)
|
let h = Math.abs(p3.alt - p4.alt)
|
||||||
let x = Math.sqrt(Math.pow(h, 2) + Math.pow(d, 2))
|
let x = Math.sqrt(Math.pow(h, 2) + Math.pow(d, 2))
|
||||||
if (shuiping == 0.00) {
|
if (shuiping == 0.00) {
|
||||||
|
|||||||
@ -47,6 +47,11 @@ class ContourAnalysis {
|
|||||||
YJ.Analysis.AnalysesResults.push(this)
|
YJ.Analysis.AnalysesResults.push(this)
|
||||||
this.createNewLine();
|
this.createNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get type() {
|
||||||
|
return 'ContourAnalysis'
|
||||||
|
}
|
||||||
|
|
||||||
createNewLine() {
|
createNewLine() {
|
||||||
ContourAnalysis.interpolatePoint(this);
|
ContourAnalysis.interpolatePoint(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import DrawPolygon from "../../../Draw/drawPolygon"
|
|||||||
import Tools from "../../../Tools";
|
import Tools from "../../../Tools";
|
||||||
import { closeRotateAround, closeViewFollow} from '../../../Global/global'
|
import { closeRotateAround, closeViewFollow} from '../../../Global/global'
|
||||||
class Submerge extends Tools {
|
class Submerge extends Tools {
|
||||||
|
#_isupdate = false
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param sdk
|
* @param sdk
|
||||||
@ -158,10 +159,12 @@ class Submerge extends Tools {
|
|||||||
e_risingSpeed[0].value = that.options.risingSpeed
|
e_risingSpeed[0].value = that.options.risingSpeed
|
||||||
e_risingSpeed[1].value = that.options.risingSpeed
|
e_risingSpeed[1].value = that.options.risingSpeed
|
||||||
e_risingSpeed[0].addEventListener('input', e => {
|
e_risingSpeed[0].addEventListener('input', e => {
|
||||||
|
that.#_isupdate = true
|
||||||
that.options.risingSpeed = Number(e.target.value);
|
that.options.risingSpeed = Number(e.target.value);
|
||||||
});
|
});
|
||||||
e_risingSpeed[1].addEventListener('input', e => {
|
e_risingSpeed[1].addEventListener('input', e => {
|
||||||
if (e.data != '.') {
|
if (e.data != '.') {
|
||||||
|
that.#_isupdate = true
|
||||||
let value = Number(e.target.value)
|
let value = Number(e.target.value)
|
||||||
let max = Number(e_risingSpeed[0].max)
|
let max = Number(e_risingSpeed[0].max)
|
||||||
let min = Number(e_risingSpeed[0].min)
|
let min = Number(e_risingSpeed[0].min)
|
||||||
@ -191,6 +194,7 @@ class Submerge extends Tools {
|
|||||||
e_minWaterLevel.value = that.options.minWaterLevel
|
e_minWaterLevel.value = that.options.minWaterLevel
|
||||||
e_minWaterLevel.addEventListener('input', e => {
|
e_minWaterLevel.addEventListener('input', e => {
|
||||||
if (e.data != '.') {
|
if (e.data != '.') {
|
||||||
|
that.#_isupdate = true
|
||||||
let value = Number(e.target.value)
|
let value = Number(e.target.value)
|
||||||
if (value > 999999999) {
|
if (value > 999999999) {
|
||||||
value = 999999999
|
value = 999999999
|
||||||
@ -216,6 +220,7 @@ class Submerge extends Tools {
|
|||||||
e_maxWaterLevel.value = that.options.maxWaterLevel
|
e_maxWaterLevel.value = that.options.maxWaterLevel
|
||||||
e_maxWaterLevel.addEventListener('input', e => {
|
e_maxWaterLevel.addEventListener('input', e => {
|
||||||
if (e.data != '.') {
|
if (e.data != '.') {
|
||||||
|
that.#_isupdate = true
|
||||||
let value = Number(e.target.value)
|
let value = Number(e.target.value)
|
||||||
if (value > 999999999) {
|
if (value > 999999999) {
|
||||||
value = 999999999
|
value = 999999999
|
||||||
@ -250,6 +255,7 @@ class Submerge extends Tools {
|
|||||||
e_waterVolume.value = that.options.waterVolume
|
e_waterVolume.value = that.options.waterVolume
|
||||||
e_waterVolume.addEventListener('input', e => {
|
e_waterVolume.addEventListener('input', e => {
|
||||||
if (e.data != '.') {
|
if (e.data != '.') {
|
||||||
|
that.#_isupdate = true
|
||||||
let value = Number(e.target.value)
|
let value = Number(e.target.value)
|
||||||
if (value > 99999999999999) {
|
if (value > 99999999999999) {
|
||||||
value = 99999999999999
|
value = 99999999999999
|
||||||
@ -319,19 +325,24 @@ class Submerge extends Tools {
|
|||||||
if (this.TweenAnimate) {
|
if (this.TweenAnimate) {
|
||||||
TWEEN.remove(this.TweenAnimate)
|
TWEEN.remove(this.TweenAnimate)
|
||||||
}
|
}
|
||||||
let totalTime = ((this.options.maxWaterLevel - this.options.minWaterLevel) / this.options.risingSpeed) * 1000
|
this.#_isupdate = false
|
||||||
this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => {
|
|
||||||
this.currentWaterLaver = r.waterLevel
|
|
||||||
}).start()
|
|
||||||
let contentElm = this._DialogObject._element.body
|
let contentElm = this._DialogObject._element.body
|
||||||
let pauseBtn = contentElm.getElementsByClassName('pause')[0];
|
let pauseBtn = contentElm.getElementsByClassName('pause')[0];
|
||||||
let startBtn = contentElm.getElementsByClassName('start')[0];
|
let startBtn = contentElm.getElementsByClassName('start')[0];
|
||||||
|
let totalTime = ((this.options.maxWaterLevel - this.options.minWaterLevel) / this.options.risingSpeed) * 1000
|
||||||
|
this.TweenAnimate = new TWEEN.Tween({ waterLevel: this.options.minWaterLevel }).to({ waterLevel: this.options.maxWaterLevel }, totalTime).delay(this.delay).easing(TWEEN.Easing.Linear.None).onUpdate(async (r, a) => {
|
||||||
|
this.currentWaterLaver = r.waterLevel
|
||||||
|
}).onComplete(()=>{
|
||||||
|
startBtn.style.display = 'flex'
|
||||||
|
pauseBtn.style.display = 'none'
|
||||||
|
}).start()
|
||||||
startBtn.style.display = 'none'
|
startBtn.style.display = 'none'
|
||||||
pauseBtn.style.display = 'flex'
|
pauseBtn.style.display = 'flex'
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
this.currentWaterLaver = this.options.minWaterLevel
|
this.currentWaterLaver = this.options.minWaterLevel
|
||||||
|
this.#_isupdate = false
|
||||||
let isPaused = false
|
let isPaused = false
|
||||||
if (this.TweenAnimate) {
|
if (this.TweenAnimate) {
|
||||||
isPaused = this.TweenAnimate._isPaused
|
isPaused = this.TweenAnimate._isPaused
|
||||||
@ -348,8 +359,18 @@ class Submerge extends Tools {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (this.TweenAnimate) {
|
if (this.TweenAnimate) {
|
||||||
|
if(this.#_isupdate) {
|
||||||
|
this.move()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(this.TweenAnimate._isPlaying) {
|
||||||
this.TweenAnimate.resume()
|
this.TweenAnimate.resume()
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.TweenAnimate.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pause() {
|
pause() {
|
||||||
if (this.TweenAnimate) {
|
if (this.TweenAnimate) {
|
||||||
|
|||||||
@ -397,6 +397,9 @@ class ViewShedStage extends Tools {
|
|||||||
ctx.fillText(item.text, 44, 28 + (index * 26));
|
ctx.fillText(item.text, 44, 28 + (index * 26));
|
||||||
imagesLoaded++;
|
imagesLoaded++;
|
||||||
if (imagesLoaded === data.length) {
|
if (imagesLoaded === data.length) {
|
||||||
|
if (that.viewBillboardPrimitive) {
|
||||||
|
that.viewer.scene.primitives.remove(that.viewBillboardPrimitive)
|
||||||
|
}
|
||||||
that.viewBillboardPrimitive = that.viewer.scene.primitives.add(new Cesium.BillboardCollection())
|
that.viewBillboardPrimitive = that.viewer.scene.primitives.add(new Cesium.BillboardCollection())
|
||||||
that.viewBillboardPrimitive.add({
|
that.viewBillboardPrimitive.add({
|
||||||
position: Cesium.Cartesian3.fromDegrees(that.viewPosition.lng, that.viewPosition.lat, that.viewPosition.alt + that.viewPointHeight),
|
position: Cesium.Cartesian3.fromDegrees(that.viewPosition.lng, that.viewPosition.lat, that.viewPosition.alt + that.viewPointHeight),
|
||||||
|
|||||||
@ -63,11 +63,15 @@ class VisibilityAnalysis extends Tools {
|
|||||||
that.tip.set_text("左键创建视角终点,右键结束通视分析")
|
that.tip.set_text("左键创建视角终点,右键结束通视分析")
|
||||||
if (!that.resultObject.viewPoint) {
|
if (!that.resultObject.viewPoint) {
|
||||||
let pos84 = that.cartesian3Towgs84(cartesian, that.viewer)
|
let pos84 = that.cartesian3Towgs84(cartesian, that.viewer)
|
||||||
let positions = await Cesium.sampleTerrainMostDetailed(
|
let positions
|
||||||
|
if(that.sdk.viewer.terrainProvider.availability)
|
||||||
|
{
|
||||||
|
positions = await Cesium.sampleTerrainMostDetailed(
|
||||||
that.sdk.viewer.terrainProvider,
|
that.sdk.viewer.terrainProvider,
|
||||||
[Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)]
|
[Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)]
|
||||||
);
|
);
|
||||||
if (positions[0].height > pos84.alt) {
|
}
|
||||||
|
if (positions && positions[0].height > pos84.alt) {
|
||||||
pos84.alt = positions[0].height
|
pos84.alt = positions[0].height
|
||||||
}
|
}
|
||||||
pos84.alt = pos84.alt + that.viewPointHeight
|
pos84.alt = pos84.alt + that.viewPointHeight
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class PolygonObject extends Base {
|
|||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -105,7 +105,7 @@ class PolygonObject extends Base {
|
|||||||
this.entity.polygon.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polygon.material = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -218,7 +218,7 @@ class PolygonObject extends Base {
|
|||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -292,7 +292,7 @@ class PolygonObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -311,7 +311,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -411,7 +411,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -438,7 +438,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -464,7 +464,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1013,7 +1013,7 @@ class PolygonObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1027,7 +1027,7 @@ class PolygonObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1041,7 +1041,7 @@ class PolygonObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1055,7 +1055,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1069,7 +1069,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1083,7 +1083,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -22,25 +22,64 @@ class AssembleObject extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @description 集结地
|
* @description 集结地
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param {Array.<object>} options.positions 坐标数组 [{lon,lat,alt},...]
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.line {object} 边框
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.line.width=2 {string} 边框宽
|
||||||
|
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||||
|
* @param {Array.<object>} options.positions 必填,经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
||||||
|
* @param options.positions[].lng {number} 经度
|
||||||
|
* @param options.positions[].lat {number} 纬度
|
||||||
|
* @param options.positions[].alt {number} 高度
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link={} {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "#ff000080"
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.positions = options.positions || []
|
this.options.positions = options.positions || []
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
this.entity
|
this.entity
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
@ -57,8 +96,8 @@ class AssembleObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -106,31 +145,31 @@ class AssembleObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.color = c
|
this.color = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -238,25 +277,25 @@ class AssembleObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -268,10 +307,10 @@ class AssembleObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineColor && this._elms.lineColor.forEach((item) => {
|
this._elms.lineColor && this._elms.lineColor.forEach((item) => {
|
||||||
item.value = v
|
item.value = this.options.line.width
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +358,7 @@ class AssembleObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -353,7 +392,7 @@ class AssembleObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -453,7 +492,7 @@ class AssembleObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -464,7 +503,7 @@ class AssembleObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -480,7 +519,7 @@ class AssembleObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -506,7 +545,7 @@ class AssembleObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1171,7 +1210,7 @@ class AssembleObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('assemble-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('assemble-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1185,7 +1224,7 @@ class AssembleObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1199,7 +1238,7 @@ class AssembleObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1213,7 +1252,7 @@ class AssembleObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labellineColorPicker = new ewPlugins('colorpicker', {
|
let labellineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1227,7 +1266,7 @@ class AssembleObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1241,7 +1280,7 @@ class AssembleObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -22,25 +22,67 @@ class AttackArrowObject extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @description 箭头面
|
* @description 箭头面
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param {Array.<object>} options.positions 坐标数组 [{lon,lat,alt},...]
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.line {object} 边框
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.line.width=2 {string} 边框宽
|
||||||
|
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||||
|
* @param {Array.<object>} options.positions 必填,经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
||||||
|
* @param options.positions[].lng {number} 经度
|
||||||
|
* @param options.positions[].lat {number} 纬度
|
||||||
|
* @param options.positions[].alt {number} 高度
|
||||||
|
* @param options.spreadState=false {boolean} 动画
|
||||||
|
* @param options.loop=false {loop} 动画重复
|
||||||
|
* @param options.spreadTime=3000 {number} 动画持续时长(毫秒)
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link={} {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "#ff000080"
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.positions = options.positions || []
|
this.options.positions = options.positions || []
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
this.entity
|
this.entity
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
@ -61,8 +103,8 @@ class AttackArrowObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -110,31 +152,31 @@ class AttackArrowObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.color = c
|
this.color = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -243,25 +285,25 @@ class AttackArrowObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -273,8 +315,8 @@ class AttackArrowObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineColor && this._elms.lineColor.forEach((item) => {
|
this._elms.lineColor && this._elms.lineColor.forEach((item) => {
|
||||||
item.value = v
|
item.value = v
|
||||||
})
|
})
|
||||||
@ -324,7 +366,7 @@ class AttackArrowObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -358,7 +400,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -458,7 +500,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -469,7 +511,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -485,7 +527,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -511,7 +553,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -851,7 +893,7 @@ class AttackArrowObject extends Base {
|
|||||||
}
|
}
|
||||||
that.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
that.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
let positionsA = that.computeAttackArrow(that.options.positions)
|
let positionsA = that.computeAttackArrow(that.options.positions)
|
||||||
if (positionsA.length == 0) {
|
if (positionsA.length == 0 || Array.isArray(positionsA[0])) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1182,7 +1224,7 @@ class AttackArrowObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('attack-arrow-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('attack-arrow-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1196,7 +1238,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1210,7 +1252,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1224,7 +1266,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labellineColorPicker = new ewPlugins('colorpicker', {
|
let labellineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1238,7 +1280,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1252,7 +1294,7 @@ class AttackArrowObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -2147,6 +2189,7 @@ class AttackArrowObject extends Base {
|
|||||||
|
|
||||||
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
|
if (that.options.positions.length > 3) {
|
||||||
that.options.positions.pop()
|
that.options.positions.pop()
|
||||||
that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1])
|
that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1])
|
||||||
that.nodePoints.pop()
|
that.nodePoints.pop()
|
||||||
@ -2161,9 +2204,9 @@ class AttackArrowObject extends Base {
|
|||||||
selectPoint.index = selectPoint.index - 1
|
selectPoint.index = selectPoint.index - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
that.renewPositions()
|
that.renewPositions()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||||
@ -2275,7 +2318,7 @@ class AttackArrowObject extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let arr = this.computeAttackArrow(positions84)
|
let arr = this.computeAttackArrow(positions84)
|
||||||
if (arr.length == 0) {
|
if (arr.length == 0 || Array.isArray(arr[0])) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
this.entity.polygon.hierarchy = new Cesium.CallbackProperty(function () {
|
||||||
@ -2296,7 +2339,7 @@ class AttackArrowObject extends Base {
|
|||||||
options.y = (options.y || options.y === 0) ? options.y : 10
|
options.y = (options.y || options.y === 0) ? options.y : 10
|
||||||
|
|
||||||
let positions = this.computeAttackArrow(this.options.positions)
|
let positions = this.computeAttackArrow(this.options.positions)
|
||||||
if (positions.length == 0) {
|
if (positions.length == 0 || Array.isArray(positions[0])) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let points = [[]]
|
let points = [[]]
|
||||||
@ -2567,11 +2610,13 @@ class AttackArrowObject extends Base {
|
|||||||
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
this.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
|
|
||||||
let positionsA = this.computeAttackArrow(positions)
|
let positionsA = this.computeAttackArrow(positions)
|
||||||
if (positionsA.length == 0) {
|
if (positionsA.length == 0 || Array.isArray(positionsA[0])) {
|
||||||
|
this.positionsH = [this.positions[0], this.positions[0], this.positions[0]]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let points = [[]]
|
let points = [[]]
|
||||||
let pos84 = []
|
let pos84 = []
|
||||||
|
|
||||||
for (let i = 0; i < positionsA.length; i++) {
|
for (let i = 0; i < positionsA.length; i++) {
|
||||||
let position = this.cartesian3Towgs84(positionsA[i], this.sdk.viewer)
|
let position = this.cartesian3Towgs84(positionsA[i], this.sdk.viewer)
|
||||||
pos84.push(position)
|
pos84.push(position)
|
||||||
|
|||||||
@ -33,6 +33,7 @@ class ArcgisLayer extends BaseLayer {
|
|||||||
} else {
|
} else {
|
||||||
this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(imageryProvider,)
|
this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(imageryProvider,)
|
||||||
}
|
}
|
||||||
|
this.entity._id = this.options.id
|
||||||
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
||||||
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
||||||
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class GdImagery extends BaseLayer {
|
|||||||
} else {
|
} else {
|
||||||
this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(gdLayer,)
|
this.entity = this.sdk.viewer.imageryLayers.addImageryProvider(gdLayer,)
|
||||||
}
|
}
|
||||||
|
this.entity._id = this.options.id
|
||||||
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
||||||
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
||||||
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
||||||
|
|||||||
@ -126,6 +126,7 @@ class Layer extends BaseLayer {
|
|||||||
this.entity =
|
this.entity =
|
||||||
this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer,)
|
this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer,)
|
||||||
}
|
}
|
||||||
|
this.entity._id = this.options.id
|
||||||
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
||||||
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
||||||
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class Layer3rdparty extends BaseLayer {
|
|||||||
this.entity =
|
this.entity =
|
||||||
this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer,)
|
this.sdk.viewer.scene.imageryLayers.addImageryProvider(layer,)
|
||||||
}
|
}
|
||||||
|
this.entity._id = this.options.id
|
||||||
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
for (let i = 0; i < this.sdk.viewer.imageryLayers._layers.length; i++) {
|
||||||
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
if (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider && this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type && (this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'flw' || this.sdk.viewer.imageryLayers._layers[i]._imageryProvider._type === 'jww')) {
|
||||||
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
let layer = this.sdk.viewer.imageryLayers._layers[i]
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import Dialog from '../../../Element/Dialog';
|
import Dialog from '../../../Element/Dialog';
|
||||||
import CoordTransform from "../../../../transform/CoordTransform";
|
import CoordTransform from "../../../../transform/CoordTransform";
|
||||||
import BaseSource from "../index";
|
import BaseSource from "../index";
|
||||||
import { syncData } from '../../../../Global/MultiViewportMode'
|
import { syncData, get2DView } from '../../../../Global/MultiViewportMode'
|
||||||
import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData } from '../../../../Global/SplitScreen'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
|
||||||
|
|
||||||
@ -28,11 +28,11 @@ class BaseLayer extends BaseSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get layerIndex() {
|
get layerIndex() {
|
||||||
return this.entity._layerIndex
|
return this.entity ? this.entity._layerIndex : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
get layer_index() {
|
get layer_index() {
|
||||||
return this.entity._layerIndex
|
return this.entity ? this.entity._layerIndex : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
get brightness() {
|
get brightness() {
|
||||||
@ -244,8 +244,19 @@ class BaseLayer extends BaseSource {
|
|||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
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)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
let sdk2D = get2DView()
|
||||||
|
if (sdk2D && sdk2D != this.sdk) {
|
||||||
|
for(let i=0;i<sdk2D.viewer.imageryLayers._layers.length;i++) {
|
||||||
|
let layer = sdk2D.viewer.imageryLayers._layers[i]
|
||||||
|
if(layer._id && layer._id == this.options.id) {
|
||||||
|
layer.alpha = this.options.alpha
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
closeCallBack: () => {
|
closeCallBack: () => {
|
||||||
this.reset()
|
this.reset()
|
||||||
|
|||||||
@ -56,7 +56,7 @@ function html(that) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<span class="label">视野缩放</span>
|
<span class="label" style="flex: 0 0 60px;">固定大小</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="scaleByDistance">
|
<input class="btn-switch" type="checkbox" @model="scaleByDistance">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class Model extends BaseModel {
|
|||||||
* @description 加载模型
|
* @description 加载模型
|
||||||
* @param sdk {object} sdk
|
* @param sdk {object} sdk
|
||||||
* @param options {object} 模型参数
|
* @param options {object} 模型参数
|
||||||
* @param options.id {string} 对象id
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 模型显隐
|
* @param options.show=true {boolean} 模型显隐
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.url {string} 资源地址
|
* @param options.url {string} 资源地址
|
||||||
@ -30,9 +30,9 @@ class Model extends BaseModel {
|
|||||||
* @param options.position.lat {number} 纬度
|
* @param options.position.lat {number} 纬度
|
||||||
* @param options.position.alt {number} 高度
|
* @param options.position.alt {number} 高度
|
||||||
* @param options.scale {object} 比例
|
* @param options.scale {object} 比例
|
||||||
* @param options.scale.x=1 {number} 比例
|
* @param options.scale.x=1 {number} x轴比例
|
||||||
* @param options.scale.y=1 {number} 比例
|
* @param options.scale.y=1 {number} y轴比例
|
||||||
* @param options.scale.z=1 {number} 比例
|
* @param options.scale.z=1 {number} z轴比例
|
||||||
* @param options.maximumScale=100 {number} 最大比例
|
* @param options.maximumScale=100 {number} 最大比例
|
||||||
* @param options.minimumPixelSize=60 {number} 最小像素
|
* @param options.minimumPixelSize=60 {number} 最小像素
|
||||||
* @param options.scaleByDistance=true {boolean} 随视野缩放
|
* @param options.scaleByDistance=true {boolean} 随视野缩放
|
||||||
@ -40,7 +40,39 @@ class Model extends BaseModel {
|
|||||||
* @param options.rotate.x {number} x轴旋转度数
|
* @param options.rotate.x {number} x轴旋转度数
|
||||||
* @param options.rotate.y {number} y轴旋转度数
|
* @param options.rotate.y {number} y轴旋转度数
|
||||||
* @param options.rotate.z {number} z轴旋转度数
|
* @param options.rotate.z {number} z轴旋转度数
|
||||||
* @param options.img {string} 图片地址
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param {object} options.attribute.link={} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(earth, options = {}, _Dialog = {}) {
|
constructor(earth, options = {}, _Dialog = {}) {
|
||||||
super(earth, options, _Dialog = {})
|
super(earth, options, _Dialog = {})
|
||||||
@ -100,8 +132,8 @@ class Model extends BaseModel {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -145,15 +177,7 @@ class Model extends BaseModel {
|
|||||||
if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.scene) {
|
if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.scene) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!url.startsWith("http")) {
|
url = this.replaceHost(url, this.options.host)
|
||||||
//说明是本地的json,在磁盘中存在的
|
|
||||||
if (!url.includes(":")) {
|
|
||||||
if (this.options.host) {
|
|
||||||
let o = new URL(url, this.options.host)
|
|
||||||
url = o.href
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// this.handler = new Cesium.ScreenSpaceEventHandler(
|
// this.handler = new Cesium.ScreenSpaceEventHandler(
|
||||||
// this.sdk.viewer.canvas
|
// this.sdk.viewer.canvas
|
||||||
// )
|
// )
|
||||||
@ -447,7 +471,7 @@ class Model extends BaseModel {
|
|||||||
this.entity.color = Cesium.Color.fromCssColorString(v)
|
this.entity.color = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -645,7 +669,7 @@ class Model extends BaseModel {
|
|||||||
|
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label && (this.label.show = v)
|
this.label && (this.label.show = v)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -679,7 +703,7 @@ class Model extends BaseModel {
|
|||||||
this.label && (this.label.color = v)
|
this.label && (this.label.color = v)
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -780,7 +804,7 @@ class Model extends BaseModel {
|
|||||||
this.label && (this.label.lineColor = v)
|
this.label && (this.label.lineColor = v)
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -791,7 +815,7 @@ class Model extends BaseModel {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -807,7 +831,7 @@ class Model extends BaseModel {
|
|||||||
this.label && (this.label.backgroundColor = [v, this.label.backgroundColor[1]])
|
this.label && (this.label.backgroundColor = [v, this.label.backgroundColor[1]])
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -833,7 +857,7 @@ class Model extends BaseModel {
|
|||||||
this.label && (this.label.backgroundColor = [this.label.backgroundColor[0], v])
|
this.label && (this.label.backgroundColor = [this.label.backgroundColor[0], v])
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1336,7 +1360,9 @@ class Model extends BaseModel {
|
|||||||
this.name = this.options.name || '未命名对象'
|
this.name = this.options.name || '未命名对象'
|
||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
let cdoptions = this.deepCopyObj(this.options)
|
||||||
|
cdoptions.host = ''
|
||||||
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(cdoptions)
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
},
|
},
|
||||||
@ -1425,7 +1451,7 @@ class Model extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1439,7 +1465,7 @@ class Model extends BaseModel {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1453,7 +1479,7 @@ class Model extends BaseModel {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1467,7 +1493,7 @@ class Model extends BaseModel {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1481,7 +1507,7 @@ class Model extends BaseModel {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -381,7 +381,7 @@ class Model2 extends BaseModel {
|
|||||||
this.entity.color = Cesium.Color.fromCssColorString(v)
|
this.entity.color = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -583,7 +583,7 @@ class Model2 extends BaseModel {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -676,7 +676,7 @@ class Model2 extends BaseModel {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -704,7 +704,7 @@ class Model2 extends BaseModel {
|
|||||||
this.label.backgroundColor = [v, this.labelBackgroundColorEnd]
|
this.label.backgroundColor = [v, this.labelBackgroundColorEnd]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -732,7 +732,7 @@ class Model2 extends BaseModel {
|
|||||||
this.label.backgroundColor = [this.labelBackgroundColorStart, v]
|
this.label.backgroundColor = [this.labelBackgroundColorStart, v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1098,7 +1098,7 @@ class Model2 extends BaseModel {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('model-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('model-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1112,7 +1112,7 @@ class Model2 extends BaseModel {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("label_color")[0],
|
el: contentElm.getElementsByClassName("label_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1126,7 +1126,7 @@ class Model2 extends BaseModel {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("line_color")[0],
|
el: contentElm.getElementsByClassName("line_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1140,7 +1140,7 @@ class Model2 extends BaseModel {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1154,7 +1154,7 @@ class Model2 extends BaseModel {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -78,6 +78,11 @@ class BaseTerrain extends BaseSource {
|
|||||||
close() {
|
close() {
|
||||||
this.sdk.viewer.scene.terrainProvider =
|
this.sdk.viewer.scene.terrainProvider =
|
||||||
new Cesium.EllipsoidTerrainProvider({})
|
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)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
|
||||||
clearTimeout(this.#updateModelTimeout)
|
clearTimeout(this.#updateModelTimeout)
|
||||||
@ -247,7 +252,9 @@ class BaseTerrain extends BaseSource {
|
|||||||
}
|
}
|
||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
let cdoptions = this.deepCopyObj(this.options)
|
||||||
|
cdoptions.host = ''
|
||||||
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(cdoptions)
|
||||||
},
|
},
|
||||||
// resetCallBack: () => {
|
// resetCallBack: () => {
|
||||||
// this.name = this.originalOptions.name
|
// this.name = this.originalOptions.name
|
||||||
|
|||||||
@ -230,6 +230,17 @@ class Tileset extends BaseTileset {
|
|||||||
else {
|
else {
|
||||||
this.rotationEditing = true
|
this.rotationEditing = true
|
||||||
}
|
}
|
||||||
|
if (!this.tileset.root.transform) {
|
||||||
|
if (window.ELEMENT) {
|
||||||
|
window.ELEMENT.Message.closeAll();
|
||||||
|
window.ELEMENT.Message({
|
||||||
|
message: '该模型不支持移动和旋转!',
|
||||||
|
type: 'warning',
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
},
|
},
|
||||||
translationalCallBack: () => {
|
translationalCallBack: () => {
|
||||||
if (this.positionEditing) {
|
if (this.positionEditing) {
|
||||||
@ -238,6 +249,17 @@ class Tileset extends BaseTileset {
|
|||||||
else {
|
else {
|
||||||
this.positionEditing = true
|
this.positionEditing = true
|
||||||
}
|
}
|
||||||
|
if (!this.tileset.root.transform) {
|
||||||
|
if (window.ELEMENT) {
|
||||||
|
window.ELEMENT.Message.closeAll();
|
||||||
|
window.ELEMENT.Message({
|
||||||
|
message: '该模型不支持移动和旋转!',
|
||||||
|
type: 'warning',
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, true)
|
}, true)
|
||||||
document.getElementsByTagName('head')[0].appendChild(this._element_style);
|
document.getElementsByTagName('head')[0].appendChild(this._element_style);
|
||||||
@ -263,14 +285,14 @@ class Tileset extends BaseTileset {
|
|||||||
//更新模型位置
|
//更新模型位置
|
||||||
updateModel(_tx, _ty, _tz, _rx = 0, _ry = 0, _rz = 0, s = 1) {
|
updateModel(_tx, _ty, _tz, _rx = 0, _ry = 0, _rz = 0, s = 1) {
|
||||||
if (!this.tileset.root.transform) {
|
if (!this.tileset.root.transform) {
|
||||||
if (window.ELEMENT) {
|
// if (window.ELEMENT) {
|
||||||
window.ELEMENT.Message.closeAll();
|
// window.ELEMENT.Message.closeAll();
|
||||||
window.ELEMENT.Message({
|
// window.ELEMENT.Message({
|
||||||
message: '该模型不支持移动和旋转!',
|
// message: '该模型不支持移动和旋转!',
|
||||||
type: 'warning',
|
// type: 'warning',
|
||||||
duration: 1500
|
// duration: 1500
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
console.warn('该模型不支持移动和旋转!')
|
console.warn('该模型不支持移动和旋转!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/Obj/Base/BatchModel/_element.js
Normal file
24
src/Obj/Base/BatchModel/_element.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
function html() {
|
||||||
|
return `
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col add-type-box">
|
||||||
|
<span class="label" style="flex: 0 0 56px;">添加方式</span>
|
||||||
|
<div class="add-type"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">间距</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="1" max="99999" @model="spacing">
|
||||||
|
<span class="unit">米</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export { html }
|
||||||
229
src/Obj/Base/BatchModel/_element_拓展.js
Normal file
229
src/Obj/Base/BatchModel/_element_拓展.js
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
import { attributeElm } from '../../Element/elm_html'
|
||||||
|
|
||||||
|
function html(that) {
|
||||||
|
return `
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">颜色</span>
|
||||||
|
<div class="color"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row">
|
||||||
|
<div style="width: 46%;">
|
||||||
|
<div class="row add-type-box">
|
||||||
|
<div class="lable-left-line">添加方式
|
||||||
|
<div class="input input-select add-type" style="margin-left: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="width: 50%;">
|
||||||
|
<div class="row" style="margin-bottom: 5px;">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">朝向偏移</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="deviation">
|
||||||
|
<span class="unit">°</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h4>模型间隔</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">自定义距离</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">固定距离</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">模型间隔</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="spacing">
|
||||||
|
<span class="unit">米</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h4>线型选择</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">折线</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">曲线</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">线条数量</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="lineNum">
|
||||||
|
<span class="unit">条</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">线条间隔</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="lineSpacing">
|
||||||
|
<span class="unit">米</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">随机采样</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">随机数量</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="lineNum">
|
||||||
|
<span class="unit">个</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col"></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">网格采样</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">首边间隔</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="fistLineSpacing">
|
||||||
|
<span class="unit">米</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">次边间隔</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="0" max="360" @model="secondLineSpacing">
|
||||||
|
<span class="unit">米</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="row">
|
||||||
|
<DIV-cy-tabs id="point-object-edit-tabs">
|
||||||
|
<DIV-cy-tab-pane label="空间信息">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col height-mode-box">
|
||||||
|
<span class="label" style="flex: 0 0 56px;">高度模式</span>
|
||||||
|
<div class="height-mode"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div style="width: 46%;">
|
||||||
|
<div class="row add-type-box">
|
||||||
|
<div class="lable-left-line">缩放
|
||||||
|
<div class="YJ-custom-checkbox-box" style="display: flex;align-items: center;cursor: pointer;">
|
||||||
|
<input type="checkbox" class="YJ-custom-checkbox">
|
||||||
|
<span style="margin-left: 10px; margin-bottom: 1px;user-select: none;">是否等比例缩放</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DIV-cy-tab-pane>
|
||||||
|
<DIV-cy-tab-pane label="标注风格">
|
||||||
|
<div>
|
||||||
|
<div class="row" style="margin-bottom: 10px;">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">新增模型风格设置</span>
|
||||||
|
<button @click="openRichTextEditor">初始风格</button>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<button @click="openRichTextEditor">当前风格</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row" style="margin-bottom: 10px;">
|
||||||
|
<div class="col" style="flex: 0 0 80px;">
|
||||||
|
<span class="label" style="flex: none;">显隐</span>
|
||||||
|
<input class="btn-switch" type="checkbox" @model="billboardShow">
|
||||||
|
</div>
|
||||||
|
<div class="col" style="flex: 0 0 90px;">
|
||||||
|
<span class="label" style="flex: none;">图标</span>
|
||||||
|
<div class="image-box" @click="clickChangeImage">
|
||||||
|
<img class="image" src="" alt="" @model="billboardImage">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="flex: 0 0 90px;">
|
||||||
|
<span class="label" style="flex: none;">默认图标</span>
|
||||||
|
<div class="image-box" @click="clickChangeDefaultImage">
|
||||||
|
<img class="image" src="" alt="" @model="billboardDefaultImage">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">图标倍数</span>
|
||||||
|
<div class="input-number input-number-unit-2">
|
||||||
|
<input class="input" type="number" title="" min="0.1" max="99" @model="billboardScale">
|
||||||
|
<span class="unit">倍</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4>文字设置</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col" style="flex: 0 0 80px;">
|
||||||
|
<span class="label" style="flex: none;">显隐</span>
|
||||||
|
<input class="btn-switch" type="checkbox" @model="labelShow">
|
||||||
|
</div>
|
||||||
|
<div class="col font-select-box">
|
||||||
|
<span class="label" style="flex: none;">字体选择</span>
|
||||||
|
<div class="input input-select font-select"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">文字大小</span>
|
||||||
|
<div class="input-number input-number-unit-2">
|
||||||
|
<input class="input" type="number" title="" min="1" max="99" @model="labelFontSize" style="width: 70px;">
|
||||||
|
<span class="unit">px</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">文字颜色</span>
|
||||||
|
<div class="labelColor"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DIV-cy-tab-pane>
|
||||||
|
</DIV-cy-tabs>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export { html }
|
||||||
92
src/Obj/Base/BatchModel/eventBinding.js
Normal file
92
src/Obj/Base/BatchModel/eventBinding.js
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
class eventBinding {
|
||||||
|
constructor() {
|
||||||
|
this.element = {}
|
||||||
|
}
|
||||||
|
static event = {}
|
||||||
|
|
||||||
|
getEvent(name) {
|
||||||
|
return eventBinding.event[name]
|
||||||
|
}
|
||||||
|
|
||||||
|
getEventAll() {
|
||||||
|
return eventBinding.event
|
||||||
|
}
|
||||||
|
|
||||||
|
setEvent(name, event) {
|
||||||
|
eventBinding.event[name] = event
|
||||||
|
}
|
||||||
|
|
||||||
|
on(that, elements) {
|
||||||
|
for (let i = 0; i < elements.length; i++) {
|
||||||
|
let Event = []
|
||||||
|
let isEvent = false
|
||||||
|
let removeName = []
|
||||||
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (let m of elements[i].attributes) {
|
||||||
|
switch (m.name) {
|
||||||
|
case '@model': {
|
||||||
|
isEvent = true
|
||||||
|
if (elements[i].type == 'checkbox') {
|
||||||
|
Event.push((e) => { that[m.value] = e.target.checked })
|
||||||
|
elements[i].checked = that[m.value]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Event.push((e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.type == 'number') {
|
||||||
|
value = Number(value)
|
||||||
|
}
|
||||||
|
that[m.value] = value
|
||||||
|
})
|
||||||
|
if (elements[i].nodeName == 'IMG') {
|
||||||
|
elements[i].src = that[m.value]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elements[i].value = that[m.value]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.element[m.value]) {
|
||||||
|
this.element[m.value].push(elements[i])
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.element[m.value] = [elements[i]]
|
||||||
|
}
|
||||||
|
removeName.push(m.name)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '@click': {
|
||||||
|
elements[i].addEventListener('click', (e) => {
|
||||||
|
if (typeof (that.Dialog[m.value]) === 'function') {
|
||||||
|
that.Dialog[m.value](e)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
removeName.push(m.name)
|
||||||
|
// elements[i].attributes.removeNamedItem(m.name)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// elements[i].attributes[m] = undefined
|
||||||
|
}
|
||||||
|
for (let n = 0; n < removeName.length; n++) {
|
||||||
|
elements[i].attributes.removeNamedItem(removeName[n])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEvent) {
|
||||||
|
let ventType = 'input'
|
||||||
|
if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') {
|
||||||
|
ventType = 'change'
|
||||||
|
}
|
||||||
|
elements[i].addEventListener(ventType, (e) => {
|
||||||
|
for (let t = 0; t < Event.length; t++) {
|
||||||
|
Event[t](e)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const EventBinding = new eventBinding();
|
||||||
|
export default EventBinding;
|
||||||
713
src/Obj/Base/BatchModel/index.js
Normal file
713
src/Obj/Base/BatchModel/index.js
Normal file
@ -0,0 +1,713 @@
|
|||||||
|
/**
|
||||||
|
* @description 批量模型
|
||||||
|
*/
|
||||||
|
import Dialog from '../../Element/Dialog';
|
||||||
|
import { html } from "./_element";
|
||||||
|
import EventBinding from '../../Element/Dialog/eventBinding';
|
||||||
|
import Base from "../index";
|
||||||
|
import Tools from "../../../Tools";
|
||||||
|
import { syncData } from '../../../Global/MultiViewportMode'
|
||||||
|
import Model from '../BaseSource/BaseModel/Model'
|
||||||
|
import { legp } from '../../Element/datalist'
|
||||||
|
|
||||||
|
import DrawPolyline from '../../../Draw/drawPolyline'
|
||||||
|
import DrawPolygon from '../../../Draw/drawPolygon'
|
||||||
|
import DrawThreeRect from '../../../Draw/drawThreeRect'
|
||||||
|
import DrawPoint from '../../../Draw/drawPoint'
|
||||||
|
import { setActiveViewer, closeRotateAround, closeViewFollow, CesiumContainer } from '../../../Global/global'
|
||||||
|
|
||||||
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
|
|
||||||
|
class BatchModel extends Base {
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
|
* @description 批量模型
|
||||||
|
* @param options {object} 批量模型属性
|
||||||
|
* @param options.name=未命名对象 {string} 名称
|
||||||
|
* @param options.type=polygon {string} 线类型(line,polygon)
|
||||||
|
* @param options.url=polygon {string} 线类型(line,polygon,point)
|
||||||
|
* @param options.spacing= {number} 间距
|
||||||
|
* @param options.show=true {boolean}
|
||||||
|
* @param Dialog {object} 弹框对象
|
||||||
|
* @param Dialog.confirmCallBack {function} 弹框确认时的回调
|
||||||
|
* */
|
||||||
|
constructor(sdk, options = {}, callback = null, _Dialog = {}) {
|
||||||
|
super(sdk, options);
|
||||||
|
this.viewer = this.sdk.viewer
|
||||||
|
this.options.name = options.name || '批量模型'
|
||||||
|
this.options.type = options.type || '面'
|
||||||
|
this.options.url = options.url || ''
|
||||||
|
this.options.spacing = options.spacing * 1 || 50
|
||||||
|
this.options.positions = options.positions || []
|
||||||
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
|
this.callback = callback
|
||||||
|
this.Dialog = _Dialog
|
||||||
|
this._EventBinding = new EventBinding()
|
||||||
|
this._elms = {};
|
||||||
|
this.pointArr = []
|
||||||
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
|
let tools = new Tools(sdk)
|
||||||
|
// BatchModel.computeDis(this)
|
||||||
|
// if (this.options.positions.length > 0 || this.options.positions.lng) {
|
||||||
|
if (this.options.spacing < 0 || options.spacing * 1 === 0) {
|
||||||
|
tools.message({ type: 'warning', text: '请输入正确的间距!' })
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((options.type && options.spacing != undefined) || options.type == '点') {
|
||||||
|
// BatchModel.computeDis(this)
|
||||||
|
|
||||||
|
let Draw
|
||||||
|
switch (options.type) {
|
||||||
|
case '点':
|
||||||
|
Draw = new DrawPoint(this.sdk)
|
||||||
|
break;
|
||||||
|
case '线':
|
||||||
|
Draw = new DrawPolyline(this.sdk)
|
||||||
|
break;
|
||||||
|
case '面':
|
||||||
|
Draw = new DrawThreeRect(this.sdk)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Draw && Draw.start((a, positions) => {
|
||||||
|
this.options.positions = positions;
|
||||||
|
//判断范围是否过大
|
||||||
|
if (options.type == '面') {
|
||||||
|
let posi = positions.map(v => {
|
||||||
|
return Cesium.Cartesian3.fromDegrees(v.lng, v.lat)
|
||||||
|
})
|
||||||
|
let dis1 = Cesium.Cartesian3.distance(posi[0], posi[1])
|
||||||
|
let dis2 = Cesium.Cartesian3.distance(posi[1], posi[2])
|
||||||
|
let num1 = dis1 / this.options.spacing
|
||||||
|
let num2 = dis2 / this.options.spacing
|
||||||
|
if (num1 * num2 > 100) {
|
||||||
|
tools.message({ type: 'warning', text: '数量大于100,请重新绘制' })
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (options.type == '线') {
|
||||||
|
let posi = positions.map(v => {
|
||||||
|
return Cesium.Cartesian3.fromDegrees(v.lng, v.lat)
|
||||||
|
})
|
||||||
|
let dis = 0
|
||||||
|
for (let i = 0; i < posi.length - 2; i++) {
|
||||||
|
dis += Cesium.Cartesian3.distance(posi[i], posi[i + 1])
|
||||||
|
}
|
||||||
|
if (dis / this.options.spacing > 100) {
|
||||||
|
tools.message({ type: 'warning', text: '数量大于100,请重新绘制' })
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.callback(this.options);
|
||||||
|
(this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this)
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.edit(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算距离
|
||||||
|
static async computeDis(that) {
|
||||||
|
let fromDegreesArray = []
|
||||||
|
let arr
|
||||||
|
let posiArr = []
|
||||||
|
let array = []
|
||||||
|
if (that.options.type == '面') {
|
||||||
|
that.options.positions.forEach(item => {
|
||||||
|
fromDegreesArray.push(item.lng, item.lat)
|
||||||
|
})
|
||||||
|
// arr = that.generateInterpolatedPoints(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray), that.options.spacing)
|
||||||
|
arr = await that.computedArea(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray), that.options.spacing)
|
||||||
|
array[0] = arr
|
||||||
|
array[1] = that.calculateRoadAngle(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)[0], Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)[3])
|
||||||
|
arr.forEach((item, index) => {
|
||||||
|
const cartographic = Cesium.Cartographic.fromCartesian(
|
||||||
|
item // Cartesian3对象 {x, y, z}
|
||||||
|
);
|
||||||
|
const longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||||
|
const latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||||
|
const height = cartographic.height;
|
||||||
|
posiArr.push({
|
||||||
|
lng: longitude,
|
||||||
|
lat: latitude,
|
||||||
|
alt: height
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else if (that.options.type == '线') {
|
||||||
|
that.options.positions.forEach(item => {
|
||||||
|
fromDegreesArray.push(item.lng, item.lat)
|
||||||
|
})
|
||||||
|
array = await that.linePoint(Cesium.Cartesian3.fromDegreesArray(fromDegreesArray), that.options.spacing)
|
||||||
|
arr = array[0]
|
||||||
|
that.pointArr = arr
|
||||||
|
arr.forEach((item, index) => {
|
||||||
|
const cartographic = Cesium.Cartographic.fromCartesian(
|
||||||
|
item // Cartesian3对象 {x, y, z}
|
||||||
|
);
|
||||||
|
const longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||||
|
const latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||||
|
const height = cartographic.height;
|
||||||
|
posiArr.push({
|
||||||
|
lng: longitude,
|
||||||
|
lat: latitude,
|
||||||
|
alt: height
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else if (that.options.type == '点') {
|
||||||
|
// let height = await that.getClampToHeight({ lng: that.options.positions.lng, lat: that.options.positions.lat })
|
||||||
|
// posiArr = [{ lng: that.options.positions.lng, lat: that.options.positions.lat, alt: height }]
|
||||||
|
posiArr = [that.options.positions]
|
||||||
|
that.pointArr = posiArr
|
||||||
|
}
|
||||||
|
let params = {
|
||||||
|
type: that.options.type,
|
||||||
|
positions: posiArr,
|
||||||
|
rotate: that.options.type == '点' ? undefined : array[1]
|
||||||
|
}
|
||||||
|
that.callback(params)
|
||||||
|
// posiArr.forEach((item, index) => {
|
||||||
|
// let model = new Model(that.sdk, {
|
||||||
|
// id: 'model' + index,
|
||||||
|
// show: that.options.show,
|
||||||
|
// url: that.options.url,
|
||||||
|
// position: item,
|
||||||
|
// rotate: that.options.type == '点' ? undefined : { x: 0, y: 0, z: array[1] && (array[1][index] || array[1]) }
|
||||||
|
// })
|
||||||
|
// that.pointArr.push(model)
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
async linePoint(polygonPositions, spacing) {
|
||||||
|
let boundaryPoints = [];
|
||||||
|
let boundaryAngle = [];
|
||||||
|
for (let i = 0; i < polygonPositions.length - 1; i++) {
|
||||||
|
|
||||||
|
const start = polygonPositions[i];
|
||||||
|
const end = polygonPositions[(i + 1) % polygonPositions.length];
|
||||||
|
const segmentLength = Cesium.Cartesian3.distance(start, end);
|
||||||
|
const segments = Math.ceil(segmentLength / spacing);
|
||||||
|
|
||||||
|
for (let j = 0; j <= segments; j++) {
|
||||||
|
const ratio = j / segments;
|
||||||
|
let point = Cesium.Cartesian3.lerp(
|
||||||
|
start, end, ratio, new Cesium.Cartesian3()
|
||||||
|
);
|
||||||
|
|
||||||
|
const cartographic = Cesium.Cartographic.fromCartesian(
|
||||||
|
point // Cartesian3对象 {x, y, z}
|
||||||
|
);
|
||||||
|
const longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||||
|
const latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||||
|
|
||||||
|
|
||||||
|
let height = await this.getClampToHeight({ lng: longitude, lat: latitude })
|
||||||
|
point = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
|
||||||
|
|
||||||
|
boundaryPoints.push(point);
|
||||||
|
if (j != segments || i == polygonPositions.length - 2) {
|
||||||
|
boundaryAngle.push(this.calculateRoadAngle(start, end))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [[...new Set(boundaryPoints
|
||||||
|
.map(p => `${p.x},${p.y},${p.z}`))]
|
||||||
|
.map(str => {
|
||||||
|
const [x, y, z] = str.split(',').map(Number);
|
||||||
|
return new Cesium.Cartesian3(x, y, z);
|
||||||
|
}), boundaryAngle];
|
||||||
|
}
|
||||||
|
calculateRoadAngle(startPoint, endPoint) {
|
||||||
|
const normal = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(startPoint);
|
||||||
|
const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(startPoint, undefined, normal);
|
||||||
|
const inverseMatrix = Cesium.Matrix4.inverse(enuMatrix, new Cesium.Matrix4());
|
||||||
|
|
||||||
|
const localEnd = Cesium.Matrix4.multiplyByPoint(inverseMatrix, endPoint, new Cesium.Cartesian3());
|
||||||
|
const horizontalVec = new Cesium.Cartesian2(localEnd.x, localEnd.y);
|
||||||
|
Cesium.Cartesian2.normalize(horizontalVec, horizontalVec);
|
||||||
|
|
||||||
|
const north = new Cesium.Cartesian2(1, 0);
|
||||||
|
|
||||||
|
let angle = Cesium.Cartesian2.angleBetween(north, horizontalVec);
|
||||||
|
angle = Cesium.Math.toDegrees(angle)
|
||||||
|
const cross = Cesium.Cartesian2.cross(north, horizontalVec, new Cesium.Cartesian2());
|
||||||
|
// return cross < 0 ? angle : - angle;
|
||||||
|
return cross < 0 ? -angle : angle;
|
||||||
|
}
|
||||||
|
generateInterpolatedPoints(polygonPositions, spacing) {
|
||||||
|
// 1. 边界点插值
|
||||||
|
const boundaryPoints = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < polygonPositions.length; i++) {
|
||||||
|
|
||||||
|
const start = polygonPositions[i];
|
||||||
|
const end = polygonPositions[(i + 1) % polygonPositions.length];
|
||||||
|
const segmentLength = Cesium.Cartesian3.distance(start, end);
|
||||||
|
const segments = Math.ceil(segmentLength / spacing);
|
||||||
|
|
||||||
|
for (let j = 0; j <= segments; j++) {
|
||||||
|
const ratio = j / segments;
|
||||||
|
const point = Cesium.Cartesian3.lerp(
|
||||||
|
start, end, ratio, new Cesium.Cartesian3()
|
||||||
|
);
|
||||||
|
boundaryPoints.push(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 内部网格生成
|
||||||
|
const extent = this.computePolygonExtent(polygonPositions);
|
||||||
|
let result = this.createGridFromBBox(extent, this.options.spacing)
|
||||||
|
// const extent = Cesium.Rectangle.fromCartesianArray(polygonPositions);
|
||||||
|
|
||||||
|
const gridPoints = [];
|
||||||
|
// const polygon = new Cesium.PolygonHierarchy(polygonPositions);
|
||||||
|
var polygon = []
|
||||||
|
this.options.positions.forEach(item => {
|
||||||
|
polygon.push([item.lng, item.lat])
|
||||||
|
})
|
||||||
|
polygon.push(polygon[0])
|
||||||
|
for (let x = extent.west; x <= extent.east; x += result.lonStep) {
|
||||||
|
for (let y = extent.south; y <= extent.north; y += result.latStep) {
|
||||||
|
const position = Cesium.Cartesian3.fromDegrees(x, y);
|
||||||
|
const point = turf.point([x, y]);
|
||||||
|
const polygonTurf = turf.polygon([polygon]);
|
||||||
|
const isInside = turf.booleanPointInPolygon(point, polygonTurf);
|
||||||
|
isInside && gridPoints.push(position)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 合并结果并去重
|
||||||
|
// return [...new Set([...boundaryPoints, ...gridPoints]
|
||||||
|
return [...new Set([...gridPoints]
|
||||||
|
.map(p => `${p.x},${p.y},${p.z}`))]
|
||||||
|
.map(str => {
|
||||||
|
const [x, y, z] = str.split(',').map(Number);
|
||||||
|
return new Cesium.Cartesian3(x, y, z);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createGridFromBBox(bbox, spacing) {
|
||||||
|
const earthRadius = 6378137; // WGS84椭球体长半轴
|
||||||
|
// 计算经度方向网格数
|
||||||
|
const lonDistance = Cesium.Cartesian3.distance(
|
||||||
|
Cesium.Cartesian3.fromDegrees(bbox.west, (bbox.south + bbox.north) / 2, 0),
|
||||||
|
Cesium.Cartesian3.fromDegrees(bbox.east, (bbox.south + bbox.north) / 2, 0)
|
||||||
|
);
|
||||||
|
const lonCount = Math.ceil(lonDistance / spacing);
|
||||||
|
|
||||||
|
// 计算纬度方向网格数
|
||||||
|
const latDistance = Cesium.Cartesian3.distance(
|
||||||
|
Cesium.Cartesian3.fromDegrees((bbox.west + bbox.east) / 2, bbox.south, 0),
|
||||||
|
Cesium.Cartesian3.fromDegrees((bbox.west + bbox.east) / 2, bbox.north, 0)
|
||||||
|
);
|
||||||
|
const latCount = Math.ceil(latDistance / spacing);
|
||||||
|
// 生成网格线
|
||||||
|
const lonStep = (bbox.east - bbox.west) / lonCount;
|
||||||
|
const latStep = (bbox.north - bbox.south) / latCount;
|
||||||
|
return { lonStep, latStep }
|
||||||
|
}
|
||||||
|
|
||||||
|
computePolygonExtent(positions) {
|
||||||
|
// 计算多边形经纬度范围
|
||||||
|
const cartographics = positions.map(p =>
|
||||||
|
Cesium.Cartographic.fromCartesian(p));
|
||||||
|
const lons = cartographics.map(c => Cesium.Math.toDegrees(c.longitude));
|
||||||
|
const lats = cartographics.map(c => Cesium.Math.toDegrees(c.latitude));
|
||||||
|
return {
|
||||||
|
west: Math.min(...lons),
|
||||||
|
east: Math.max(...lons),
|
||||||
|
south: Math.min(...lats),
|
||||||
|
north: Math.max(...lats)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async computedArea(polygonPositions, spacing) {
|
||||||
|
let dis12 = Cesium.Cartesian3.distance(polygonPositions[0], polygonPositions[1]);
|
||||||
|
let dis23 = Cesium.Cartesian3.distance(polygonPositions[1], polygonPositions[2]);
|
||||||
|
let vec12 = Cesium.Cartesian3.subtract(polygonPositions[1], polygonPositions[0], new Cesium.Cartesian3());
|
||||||
|
let vec23 = Cesium.Cartesian3.subtract(polygonPositions[2], polygonPositions[1], new Cesium.Cartesian3());
|
||||||
|
|
||||||
|
let num12 = Math.ceil(dis12 / spacing);
|
||||||
|
let num23 = Math.ceil(dis23 / spacing);
|
||||||
|
|
||||||
|
let line1 = []
|
||||||
|
for (let i = 0; i < num12; i++) {
|
||||||
|
line1.push(await this.calculatePointB(polygonPositions[0], polygonPositions[1], i * spacing))
|
||||||
|
}
|
||||||
|
let line2 = []
|
||||||
|
for (let i = 0; i < num12; i++) {
|
||||||
|
line2.push(await this.calculatePointB(polygonPositions[3], polygonPositions[2], i * spacing))
|
||||||
|
}
|
||||||
|
|
||||||
|
let allPoints = []
|
||||||
|
for (let i = 0; i < line1.length; i++) {
|
||||||
|
for (let j = 0; j < num23; j++) {
|
||||||
|
allPoints.push(await this.calculatePointB(line1[i], line2[i], j * spacing))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allPoints
|
||||||
|
}
|
||||||
|
async calculatePointB(pointA, pointC, distance) {
|
||||||
|
// 将输入坐标转换为Cartesian3类型
|
||||||
|
// const pointA = Cesium.Cartesian3.fromDegrees(a.longitude, a.latitude, a.height);
|
||||||
|
// const pointC = Cesium.Cartesian3.fromDegrees(c.longitude, c.latitude, c.height);
|
||||||
|
|
||||||
|
// 计算向量AC
|
||||||
|
const vectorAC = Cesium.Cartesian3.subtract(pointC, pointA, new Cesium.Cartesian3());
|
||||||
|
|
||||||
|
// 计算向量AC的长度
|
||||||
|
const lengthAC = Cesium.Cartesian3.magnitude(vectorAC);
|
||||||
|
|
||||||
|
// 归一化向量AC
|
||||||
|
const unitVector = Cesium.Cartesian3.normalize(vectorAC, new Cesium.Cartesian3());
|
||||||
|
|
||||||
|
// 计算点B坐标
|
||||||
|
const scaledVector = Cesium.Cartesian3.multiplyByScalar(unitVector, distance, new Cesium.Cartesian3());
|
||||||
|
const pointB = Cesium.Cartesian3.add(pointA, scaledVector, new Cesium.Cartesian3());
|
||||||
|
|
||||||
|
|
||||||
|
const cartographic = Cesium.Cartographic.fromCartesian(
|
||||||
|
pointB // Cartesian3对象 {x, y, z}
|
||||||
|
);
|
||||||
|
const longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||||
|
const latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||||
|
|
||||||
|
|
||||||
|
let height = await this.getClampToHeight({ lng: longitude, lat: latitude })
|
||||||
|
let point = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
|
||||||
|
// 转换回经纬度
|
||||||
|
// const cartographic = Cesium.Cartographic.fromCartesian(pointB);
|
||||||
|
// return {
|
||||||
|
// longitude: Cesium.Math.toDegrees(cartographic.longitude),
|
||||||
|
// latitude: Cesium.Math.toDegrees(cartographic.latitude),
|
||||||
|
// height: cartographic.height
|
||||||
|
// };
|
||||||
|
// return pointB
|
||||||
|
return point
|
||||||
|
}
|
||||||
|
get show() {
|
||||||
|
return this.options.show
|
||||||
|
}
|
||||||
|
|
||||||
|
set show(v) {
|
||||||
|
this.options.show = v
|
||||||
|
for (let i = 0; i < this.pointArr.length; i++) {
|
||||||
|
this.pointArr[i].show = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get type() {
|
||||||
|
return this.options.type
|
||||||
|
}
|
||||||
|
|
||||||
|
set type(v) {
|
||||||
|
this.options.type = v
|
||||||
|
this._elms.type &&
|
||||||
|
this._elms.type.forEach(item => {
|
||||||
|
item.value = v
|
||||||
|
})
|
||||||
|
}
|
||||||
|
get spacing() {
|
||||||
|
return this.options.spacing
|
||||||
|
}
|
||||||
|
|
||||||
|
set spacing(v) {
|
||||||
|
this.options.spacing = v
|
||||||
|
this._elms.spacing &&
|
||||||
|
this._elms.spacing.forEach(item => {
|
||||||
|
item.value = v
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description 编辑框
|
||||||
|
* @param state=false {boolean} 状态: true打开, false关闭
|
||||||
|
*/
|
||||||
|
async edit(state = false) {
|
||||||
|
let _this = this
|
||||||
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
|
||||||
|
// let elms = this.sdk.viewer._container.getElementsByClassName('YJ-custom-base-dialog')
|
||||||
|
// for (let i = elms.length - 1; i >= 0; i--) {
|
||||||
|
// this.sdk.viewer._container.removeChild(elms[i])
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (this._DialogObject && this._DialogObject.close) {
|
||||||
|
this._DialogObject.close()
|
||||||
|
this._DialogObject = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
this._DialogObject = await new Dialog(this.sdk, this.originalOptions, {
|
||||||
|
title: '默认模型参数设置', left: '180px', top: '100px',
|
||||||
|
confirmCallBack: (options) => {
|
||||||
|
this.name = this.name.trim()
|
||||||
|
if (!this.name) {
|
||||||
|
// this.name = '未命名对象'
|
||||||
|
this.name = '飞线'
|
||||||
|
}
|
||||||
|
|
||||||
|
let Draw
|
||||||
|
switch (this.options.type) {
|
||||||
|
case '点':
|
||||||
|
Draw = new DrawPoint(this.sdk)
|
||||||
|
break;
|
||||||
|
case '线':
|
||||||
|
Draw = new DrawPolyline(this.sdk)
|
||||||
|
break;
|
||||||
|
case '面':
|
||||||
|
Draw = new DrawThreeRect(this.sdk)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Draw && Draw.start((a, positions) => {
|
||||||
|
this.options.positions = positions;
|
||||||
|
// this.callback(this.options);
|
||||||
|
(this.options.positions.length || this.options.positions.lng) && BatchModel.computeDis(this)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
this._DialogObject.close()
|
||||||
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
},
|
||||||
|
// resetCallBack: () => {
|
||||||
|
// this.reset()
|
||||||
|
// console.log('22222')
|
||||||
|
// this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
||||||
|
// },
|
||||||
|
// removeCallBack: () => {
|
||||||
|
// console.log('33333')
|
||||||
|
// this.Dialog.removeCallBack && this.Dialog.removeCallBack()
|
||||||
|
// },
|
||||||
|
closeCallBack: () => {
|
||||||
|
this.reset()
|
||||||
|
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
||||||
|
// color: "color('rgba(255,255,255," + this.newData.transparency + ")')",
|
||||||
|
// show: true,
|
||||||
|
// });
|
||||||
|
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
|
||||||
|
},
|
||||||
|
addFootElm: [
|
||||||
|
{
|
||||||
|
tagName: 'button',
|
||||||
|
className: 'flipe-over-y',
|
||||||
|
innerHTML: '重置',
|
||||||
|
event: [
|
||||||
|
'click',
|
||||||
|
() => {
|
||||||
|
this.reset()
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
// showCallBack: (show) => {
|
||||||
|
// this.show = show
|
||||||
|
// this.Dialog.showCallBack && this.Dialog.showCallBack()
|
||||||
|
// }
|
||||||
|
}, true)
|
||||||
|
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' flow-line-surface'
|
||||||
|
let contentElm = document.createElement('div');
|
||||||
|
contentElm.innerHTML = html()
|
||||||
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
|
// 颜色组件
|
||||||
|
// let waterColorPicker = new YJColorPicker({
|
||||||
|
// el: contentElm.getElementsByClassName("flowLine-color")[0],
|
||||||
|
// size: 'mini',//颜色box类型
|
||||||
|
// alpha: true,//是否开启透明度
|
||||||
|
// defaultColor: this.color,
|
||||||
|
// disabled: false,//是否禁止打开颜色选择器
|
||||||
|
// openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
|
// sure: (color) => {
|
||||||
|
// this.color = color
|
||||||
|
// },//点击确认按钮事件回调
|
||||||
|
// clear: () => {
|
||||||
|
// this.color = 'rgba(255,255,255,1)'
|
||||||
|
// },//点击清空按钮事件回调
|
||||||
|
// })
|
||||||
|
|
||||||
|
let all_elm = contentElm.getElementsByTagName("*")
|
||||||
|
this._EventBinding.on(this, all_elm)
|
||||||
|
this._elms = this._EventBinding.element
|
||||||
|
|
||||||
|
let nameData = [
|
||||||
|
{
|
||||||
|
name: '点',
|
||||||
|
value: '点',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '线',
|
||||||
|
value: '线',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '面',
|
||||||
|
value: '面',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let nameDataLegpObject = legp(
|
||||||
|
this._DialogObject._element.content.getElementsByClassName(
|
||||||
|
'add-type-box'
|
||||||
|
)[0],
|
||||||
|
'.add-type'
|
||||||
|
)
|
||||||
|
if (nameDataLegpObject) {
|
||||||
|
nameDataLegpObject.legp_search(nameData)
|
||||||
|
let nameDataLegpElm = this._DialogObject._element.content
|
||||||
|
.getElementsByClassName('add-type')[0]
|
||||||
|
.getElementsByTagName('input')[0]
|
||||||
|
this._elms.type = [nameDataLegpElm]
|
||||||
|
nameDataLegpElm.value = this.options.type
|
||||||
|
for (let i = 0; i < nameData.length; i++) {
|
||||||
|
if (nameData[i].value === nameDataLegpElm.value) {
|
||||||
|
nameDataLegpObject.legp_searchActive(nameData[i].value)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameDataLegpElm.addEventListener('input', () => {
|
||||||
|
for (let i = 0; i < nameData.length; i++) {
|
||||||
|
if (nameData[i].value === nameDataLegpElm.value) {
|
||||||
|
this.type = nameData[i].value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// this._elms.color = [waterColorPicker]
|
||||||
|
} else {
|
||||||
|
// if (this._element_style) {
|
||||||
|
// document.getElementsByTagName('head')[0].removeChild(this._element_style)
|
||||||
|
// this._element_style = null
|
||||||
|
// }
|
||||||
|
// if (this._DialogObject && this._DialogObject.remove) {
|
||||||
|
// this._DialogObject.remove()
|
||||||
|
// this._DialogObject = null
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawArea() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.name = this.originalOptions.name
|
||||||
|
this.type = this.originalOptions.type
|
||||||
|
this.spacing = this.originalOptions.spacing
|
||||||
|
this.show = this.originalOptions.show
|
||||||
|
this.options.spacing = this.originalOptions.spacing
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 飞到对应实体
|
||||||
|
*/
|
||||||
|
async flyTo(options = {}) {
|
||||||
|
setActiveViewer(0)
|
||||||
|
closeRotateAround(this.sdk)
|
||||||
|
closeViewFollow(this.sdk)
|
||||||
|
|
||||||
|
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
|
||||||
|
let orientation = {
|
||||||
|
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
|
||||||
|
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let lng = this.options.customView.relativePosition.lng
|
||||||
|
let lat = this.options.customView.relativePosition.lat
|
||||||
|
let alt = this.options.customView.relativePosition.alt
|
||||||
|
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
|
||||||
|
let position = { lng: 0, lat: 0 }
|
||||||
|
if (this.options.position) {
|
||||||
|
position = { ...this.options.position }
|
||||||
|
}
|
||||||
|
else if (this.options.positions) {
|
||||||
|
position = { ...this.options.positions[0] }
|
||||||
|
}
|
||||||
|
else if (this.options.center) {
|
||||||
|
position = { ...this.options.center }
|
||||||
|
}
|
||||||
|
else if (this.options.start) {
|
||||||
|
position = { ...this.options.start }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.options.hasOwnProperty('lng')) {
|
||||||
|
position.lng = this.options.lng
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('lat')) {
|
||||||
|
position.lat = this.options.lat
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('alt')) {
|
||||||
|
position.alt = this.options.alt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果没有高度值,则获取紧贴高度计算
|
||||||
|
// if (!position.hasOwnProperty('alt')) {
|
||||||
|
// position.alt = await this.getClampToHeight(position)
|
||||||
|
// }
|
||||||
|
lng = this.options.customView.relativePosition.lng + position.lng
|
||||||
|
lat = this.options.customView.relativePosition.lat + position.lat
|
||||||
|
alt = this.options.customView.relativePosition.alt + position.alt
|
||||||
|
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
this.sdk.viewer.camera.flyTo({
|
||||||
|
destination: destination,
|
||||||
|
orientation: orientation
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let positionArray = []
|
||||||
|
if (this.options.positions.length > 0) {
|
||||||
|
for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
|
this.options.positions[i].lng,
|
||||||
|
this.options.positions[i].lat,
|
||||||
|
this.options.positions[i].alt
|
||||||
|
)
|
||||||
|
positionArray.push(a.x, a.y, a.z)
|
||||||
|
}
|
||||||
|
let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray)
|
||||||
|
this.viewer.camera.flyToBoundingSphere(BoundingSphere, {
|
||||||
|
offset: {
|
||||||
|
heading: Cesium.Math.toRadians(0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(-20.0),
|
||||||
|
roll: Cesium.Math.toRadians(0.0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (this.options.positions.lng) {
|
||||||
|
let orientation = {
|
||||||
|
heading: Cesium.Math.toRadians(0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(-60.0),
|
||||||
|
roll: Cesium.Math.toRadians(0.0)
|
||||||
|
}
|
||||||
|
this.sdk.viewer.camera.flyTo({
|
||||||
|
destination: Cesium.Cartesian3.fromDegrees(this.options.positions.lng, this.options.positions.lat, this.options.positions.alt + 100),
|
||||||
|
// orientation: orientation
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
async remove() {
|
||||||
|
for (let i = 0; i < this.pointArr.length; i++) {
|
||||||
|
this.pointArr[i].remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pointArr = []
|
||||||
|
this.positions = []
|
||||||
|
this.entity = null
|
||||||
|
|
||||||
|
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
||||||
|
this._DialogObject.close()
|
||||||
|
this._DialogObject = null
|
||||||
|
}
|
||||||
|
await this.sdk.removeIncetance(this.options.id)
|
||||||
|
await syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
flicker() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BatchModel
|
||||||
@ -304,17 +304,17 @@ function html(that) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DIV-cy-tab-pane>-->
|
</DIV-cy-tab-pane>-->
|
||||||
<!-- <DIV-cy-tab-pane label="灯光控制">-->
|
<DIV-cy-tab-pane label="灯光控制">
|
||||||
<!-- <div>-->
|
<div>
|
||||||
<!-- <div class="row">-->
|
<div class="row">
|
||||||
<!-- <div class="col">-->
|
<div class="col">
|
||||||
<!-- <span class="label">指令</span>-->
|
<span class="label" style="flex: unset;">指令</span>
|
||||||
<!-- <input class="input" type="text" @model="instruct">-->
|
<input class="input" type="text" @model="instruct">
|
||||||
<!-- <button class="primary" @click="instructSubmit">提交</button>-->
|
<!-- <button class="btn" style="margin-left: 10px;" @click="instructSubmit">提交</button> -->
|
||||||
<!-- </div>-->
|
</div>
|
||||||
<!-- </div>-->
|
</div>
|
||||||
<!-- </div>-->
|
</div>
|
||||||
<!-- </DIV-cy-tab-pane>-->
|
</DIV-cy-tab-pane>
|
||||||
<!-- <DIV-cy-tab-pane label="设置操作点">-->
|
<!-- <DIV-cy-tab-pane label="设置操作点">-->
|
||||||
<!-- <div>-->
|
<!-- <div>-->
|
||||||
<!-- <div class="row">-->
|
<!-- <div class="row">-->
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
|
|||||||
import richText from "../../Element/richText";
|
import richText from "../../Element/richText";
|
||||||
import MouseEvent from '../../../Event/index'
|
import MouseEvent from '../../../Event/index'
|
||||||
import LabelObject from '../LabelObject'
|
import LabelObject from '../LabelObject'
|
||||||
import { syncData } from '../../../Global/MultiViewportMode'
|
import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
|
||||||
import { legp } from '../../Element/datalist';
|
import { legp } from '../../Element/datalist';
|
||||||
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
|
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
|
||||||
import MouseTip from '../../../MouseTip'
|
import MouseTip from '../../../MouseTip'
|
||||||
@ -21,23 +21,53 @@ class CircleDiffuse extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 圆属性
|
* @param options {object} 圆属性
|
||||||
* @param options.id {string} 标注id
|
* @param options.id {string} 标注id
|
||||||
* @param [options.show=true] {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.lng {number} 经度
|
* @param options.lng {number} 经度
|
||||||
* @param options.lat {number} 维度
|
* @param options.lat {number} 维度
|
||||||
* @param options.color=#1FA8E3 {string} 基础颜色
|
* @param options.color=#1FA8E3 {string} 基础颜色
|
||||||
* @param options.colors=[] {string} 范围颜色
|
|
||||||
* @param options.speed=5 {number} 速度
|
* @param options.speed=5 {number} 速度
|
||||||
* @param options.count=3 {number} 波纹数量
|
* @param options.count=3 {number} 波纹数量
|
||||||
* @param options.circle=[{radius, color}] {object} 圆属性;radius:半径,color:颜色
|
* @param options.circle=[]] {array} 圆属性
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.circle[].radius {number} 半径
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.circle[].color {string} 颜色
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param {object} options.attribute.link={} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
*/
|
*/
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.lng = options.lng
|
this.options.lng = options.lng
|
||||||
this.options.lat = options.lat
|
this.options.lat = options.lat
|
||||||
this.options.color = options.color || '#1FA8E3'
|
this.options.color = options.color || '#1FA8E3'
|
||||||
this.options.colors = options.colors || []
|
|
||||||
this.options.transparency = (options.transparency || options.transparency === 0) ? options.transparency : 1
|
this.options.transparency = (options.transparency || options.transparency === 0) ? options.transparency : 1
|
||||||
if (this.options.transparency > 1) {
|
if (this.options.transparency > 1) {
|
||||||
this.options.transparency = 1
|
this.options.transparency = 1
|
||||||
@ -75,8 +105,8 @@ class CircleDiffuse extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -181,7 +211,7 @@ class CircleDiffuse extends Base {
|
|||||||
}
|
}
|
||||||
that.sdk._entityZIndex++
|
that.sdk._entityZIndex++
|
||||||
if (that.sdk.viewer._element.className === 'cesium-viewer 2d') {
|
if (that.sdk.viewer._element.className === 'cesium-viewer 2d') {
|
||||||
that.entity.ellipse.height = 1000000
|
that.entity.ellipse.height = 1
|
||||||
}
|
}
|
||||||
CircleDiffuse.createLabel(that)
|
CircleDiffuse.createLabel(that)
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
@ -223,16 +253,31 @@ class CircleDiffuse extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
|
if (!this.isShowView || !sdkD) {
|
||||||
this.options.show = v
|
this.options.show = v
|
||||||
this.entity.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)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
if (this._DialogObject && this._DialogObject.showBtn) {
|
if (this._DialogObject && this._DialogObject.showBtn) {
|
||||||
this._DialogObject.showBtn.checked = v
|
this._DialogObject.showBtn.checked = v
|
||||||
}
|
}
|
||||||
if (this.options.label.show) {
|
|
||||||
this.label.show = v
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -362,6 +407,7 @@ class CircleDiffuse extends Base {
|
|||||||
return this.options.circle
|
return this.options.circle
|
||||||
}
|
}
|
||||||
set circle(v) {
|
set circle(v) {
|
||||||
|
console.log(v)
|
||||||
this.options.circle = v || [{ radius: 10 }]
|
this.options.circle = v || [{ radius: 10 }]
|
||||||
for (let i = 0; i < this.options.circle.length; i++) {
|
for (let i = 0; i < this.options.circle.length; i++) {
|
||||||
if(this.options.circle[i].radius>999999) {
|
if(this.options.circle[i].radius>999999) {
|
||||||
@ -414,21 +460,13 @@ class CircleDiffuse extends Base {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get colors() {
|
|
||||||
return this.options.colors
|
|
||||||
}
|
|
||||||
|
|
||||||
set colors(v) {
|
|
||||||
this.options.colors = v
|
|
||||||
CircleDiffuse.create(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
get labelShow() {
|
get labelShow() {
|
||||||
return this.options.label.show
|
return this.options.label.show
|
||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -462,7 +500,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -562,7 +600,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -573,7 +611,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -589,7 +627,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -615,7 +653,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1000,9 +1038,9 @@ class CircleDiffuse extends Base {
|
|||||||
else if (this.options.positions) {
|
else if (this.options.positions) {
|
||||||
position = { ...this.options.positions[0] }
|
position = { ...this.options.positions[0] }
|
||||||
}
|
}
|
||||||
else if (this.options.center) {
|
// else if (this.options.center) {
|
||||||
position = { ...this.options.center }
|
// position = { ...this.options.center }
|
||||||
}
|
// }
|
||||||
else if (this.options.start) {
|
else if (this.options.start) {
|
||||||
position = { ...this.options.start }
|
position = { ...this.options.start }
|
||||||
}
|
}
|
||||||
@ -1104,7 +1142,7 @@ class CircleDiffuse extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('circle-diffuse-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('circle-diffuse-edit-tabs', undefined, this.sdk)
|
||||||
|
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1118,7 +1156,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1132,7 +1170,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1146,7 +1184,7 @@ class CircleDiffuse extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1321,7 +1359,7 @@ class CircleDiffuse extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async remove() {
|
async remove() {
|
||||||
this.label.remove()
|
this.label && this.label.remove()
|
||||||
this.entity && this.sdk.viewer.entities.remove(this.entity)
|
this.entity && this.sdk.viewer.entities.remove(this.entity)
|
||||||
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
|
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
|
||||||
this.entity = null
|
this.entity = null
|
||||||
@ -1405,7 +1443,7 @@ class CircleDiffuse extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._radius = radius
|
this._radius = radius
|
||||||
inputElm.value = value
|
// inputElm.value = value
|
||||||
CircleDiffuse.create(this)
|
CircleDiffuse.create(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1446,11 +1484,11 @@ class CircleDiffuse extends Base {
|
|||||||
|
|
||||||
|
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: circleElm.getElementsByClassName("color")[0],
|
el: circleElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: false,//是否开启透明度
|
alpha: false,//是否开启透明度
|
||||||
defaultColor: this.options.circle[i].color,
|
defaultColor: this.options.circle[i].color || this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (color) => {
|
sure: (color) => {
|
||||||
|
|||||||
@ -18,34 +18,75 @@ import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Gl
|
|||||||
class CircleObject extends Base {
|
class CircleObject extends Base {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
* @description 创建圆
|
* @description 创建圆
|
||||||
* @param options {object} 圆属性
|
|
||||||
* @param options.id {string} 标注id
|
* @param options.id {string} 标注id
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color="#ff000080" {string} 颜色
|
||||||
* @param options.center {object} 位置
|
* @param options.center {object} 中心位置
|
||||||
* @param options.center.lng {object} 经度
|
* @param options.center.lng {number} 经度
|
||||||
* @param options.center.lat {object} 纬度
|
* @param options.center.lat {number} 纬度
|
||||||
* @param options.center.alt {object} 高度
|
* @param options.center.alt {number} 高度
|
||||||
* @param options.radius=10 {object}半径
|
* @param options.radius=10 {number}半径
|
||||||
* @param options.line {object} 边框
|
* @param options.line {object} 边框
|
||||||
* @param options.line.width=2 {string} 边框宽
|
* @param options.line.width=3 {number} 边框宽
|
||||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
* @param options.line.color="#ff000080" {string} 边框颜色
|
||||||
* @param options.label {object} 标注
|
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
*/
|
*/
|
||||||
constructor(sdk, options = {}) {
|
constructor(sdk, options = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "#ff000080"
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.radius = (options.radius || options.radius === 0) ? options.radius : 10
|
this.options.radius = (options.radius || options.radius === 0) ? options.radius : 10
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.center = options.center || {}
|
this.options.center = options.center || {}
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
options.label = options.label || {}
|
options.label = options.label || {}
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
@ -58,8 +99,8 @@ class CircleObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -216,31 +257,31 @@ class CircleObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.color = c
|
this.color = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -252,25 +293,25 @@ class CircleObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -282,8 +323,8 @@ class CircleObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
||||||
item.value = v
|
item.value = v
|
||||||
})
|
})
|
||||||
@ -333,7 +374,7 @@ class CircleObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && (!this.showView || this.showView == 3)) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -367,7 +408,7 @@ class CircleObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -467,7 +508,7 @@ class CircleObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -478,7 +519,7 @@ class CircleObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -494,7 +535,7 @@ class CircleObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -520,7 +561,7 @@ class CircleObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1151,7 +1192,7 @@ class CircleObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('circle-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('circle-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1165,7 +1206,7 @@ class CircleObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1179,7 +1220,7 @@ class CircleObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1193,7 +1234,7 @@ class CircleObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labellineColorPicker = new ewPlugins('colorpicker', {
|
let labellineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1207,7 +1248,7 @@ class CircleObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1221,7 +1262,7 @@ class CircleObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1878,7 +1919,7 @@ class CircleObject extends Base {
|
|||||||
entity = null
|
entity = null
|
||||||
}
|
}
|
||||||
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
||||||
let radius = that.computeDistance([that.options.center, endpoint])
|
let radius = that.computeDistance2([that.options.center, endpoint])
|
||||||
that.radius = radius
|
that.radius = radius
|
||||||
|
|
||||||
YJ.Measure.SetMeasureStatus(false)
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
@ -1904,7 +1945,7 @@ class CircleObject extends Base {
|
|||||||
that.event.mouse_move((movement, cartesian) => {
|
that.event.mouse_move((movement, cartesian) => {
|
||||||
entity && (entity.show = true)
|
entity && (entity.show = true)
|
||||||
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
||||||
moveRadius = that.computeDistance([that.options.center, endpoint])
|
moveRadius = that.computeDistance2([that.options.center, endpoint])
|
||||||
fromDegreesArray = that.createCircle(that.options.center, moveRadius)
|
fromDegreesArray = that.createCircle(that.options.center, moveRadius)
|
||||||
that.tip.setPosition(
|
that.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
@ -1950,7 +1991,7 @@ class CircleObject extends Base {
|
|||||||
return '半径:' + moveRadius + ' 米'
|
return '半径:' + moveRadius + ' 米'
|
||||||
}, false),
|
}, false),
|
||||||
font: '20px Microsoft YaHei',
|
font: '20px Microsoft YaHei',
|
||||||
distanceDisplayCondition: 10000000,
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
||||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
|||||||
@ -9,22 +9,15 @@ function html(that) {
|
|||||||
<span class="label">名称</span>
|
<span class="label">名称</span>
|
||||||
<input class="input" maxlength="40" type="text" @model="name">
|
<input class="input" maxlength="40" type="text" @model="name">
|
||||||
</div>
|
</div>
|
||||||
<div class="col" style="flex: 0 0 54%;">
|
<div class="col" style="flex: 0 0 56%;">
|
||||||
<div>
|
<div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col input-select-unit-box">
|
<div class="col input-select-unit-box">
|
||||||
<span class="label">原始长度:</span>
|
<div class="input-select-unit"></div>
|
||||||
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length">
|
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length">
|
||||||
<div class="input-select-unit"></div>
|
<div class="input-select-unit"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col input-select-fit-unit-box">
|
|
||||||
<span class="label">拟合长度:</span>
|
|
||||||
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="fitLength">
|
|
||||||
<div class="input-select-fit-unit"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -72,7 +65,7 @@ function html(that) {
|
|||||||
<span class="label">线条颜色</span>
|
<span class="label">线条颜色</span>
|
||||||
<div class="color"></div>
|
<div class="color"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
<span class="label">线条宽度</span>
|
<span class="label">线条宽度</span>
|
||||||
<div class="input-number input-number-unit-1" style="width: 80px;">
|
<div class="input-number input-number-unit-1" style="width: 80px;">
|
||||||
<input class="input" type="number" title="" min="1" max="999" @model="lineWidth">
|
<input class="input" type="number" title="" min="1" max="999" @model="lineWidth">
|
||||||
@ -80,7 +73,7 @@ function html(that) {
|
|||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col input-select-line-type-box">
|
<div class="col input-select-line-type-box" style="flex: 0 0 37%;">
|
||||||
<span class="label">线条形式</span>
|
<span class="label">线条形式</span>
|
||||||
<div class="input-select-line-type"></div>
|
<div class="input-select-line-type"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -90,7 +83,7 @@ function html(that) {
|
|||||||
<span class="label">线段缓冲</span>
|
<span class="label">线段缓冲</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="extend">
|
<input class="btn-switch" type="checkbox" @model="extend">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
<span class="label">缓冲宽度</span>
|
<span class="label">缓冲宽度</span>
|
||||||
<div class="input-number input-number-unit-1" style="width: 80px;">
|
<div class="input-number input-number-unit-1" style="width: 80px;">
|
||||||
<input class="input" type="number" title="" min="0" data-min="0.01" max="999999" @model="extendWidth">
|
<input class="input" type="number" title="" min="0" data-min="0.01" max="999999" @model="extendWidth">
|
||||||
@ -98,21 +91,43 @@ function html(that) {
|
|||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 37%;">
|
||||||
<span class="label">缓冲颜色</span>
|
<span class="label">缓冲颜色</span>
|
||||||
<div class="extendColor"></div>
|
<div class="extendColor"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row" id="dashTextureDom">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">动画顺向</span>
|
||||||
|
<input class="btn-switch" type="checkbox" @model="rotate">
|
||||||
|
</div>
|
||||||
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
|
<span class="label">流动速率</span>
|
||||||
|
<div class="input-number input-number-unit-1" style="width: 80px;">
|
||||||
|
<input class="input" type="number" title="" min="0" max="999999" step="1" @model="speed">
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="flex: 0 0 37%;">
|
||||||
|
<span class="label lineSpace">间距</span>
|
||||||
|
<div class="input-number input-number-unit-1 lineSpace" style="width: 80px;">
|
||||||
|
<input class="input" type="number" title="" min="0" max="4.5" step="0.1" @model="space">
|
||||||
|
<span class="unit">倍</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<span class="label">首尾相连</span>
|
<span class="label">首尾相连</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="noseToTail">
|
<input class="btn-switch" type="checkbox" @model="noseToTail">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 37%;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</DIV-cy-tab-pane>
|
</DIV-cy-tab-pane>
|
||||||
<DIV-cy-tab-pane label="标注风格">
|
<DIV-cy-tab-pane label="标注风格">
|
||||||
${labelStyleElm1()}
|
${labelStyleElm1()}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* 圆
|
* 椭圆
|
||||||
*/
|
*/
|
||||||
import Dialog from '../../Element/Dialog';
|
import Dialog from '../../Element/Dialog';
|
||||||
import cy_tabs from "../../Element/cy_html_tabs";
|
import cy_tabs from "../../Element/cy_html_tabs";
|
||||||
@ -18,13 +18,14 @@ import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Gl
|
|||||||
class EllipseObject extends Base {
|
class EllipseObject extends Base {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
* @description 创建椭圆
|
* @description 创建椭圆
|
||||||
* @param options {object} 圆属性
|
* @param options {object} 圆属性
|
||||||
* @param options.id {string} 标注id
|
* @param options.id {string} 标注id
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.center {object} 位置
|
* @param options.center {object} 中心位置
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color="rgba(255, 0, 0, 0.5)" {string} 颜色
|
||||||
* @param options.center.lng {object} 经度
|
* @param options.center.lng {object} 经度
|
||||||
* @param options.center.lat {object} 维度
|
* @param options.center.lat {object} 维度
|
||||||
* @param options.semiMinorAxis=10 {number} 短半轴长度
|
* @param options.semiMinorAxis=10 {number} 短半轴长度
|
||||||
@ -32,22 +33,55 @@ class EllipseObject extends Base {
|
|||||||
* @param options.bearing=0 {number} 旋转角度
|
* @param options.bearing=0 {number} 旋转角度
|
||||||
* @param options.line {object} 边框
|
* @param options.line {object} 边框
|
||||||
* @param options.line.width=2 {string} 边框宽
|
* @param options.line.width=2 {string} 边框宽
|
||||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
* @param options.line.color="rgba(255, 0, 0, 1)" {string} 边框颜色
|
||||||
* @param options.label {object} 标注
|
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
*/
|
*/
|
||||||
constructor(sdk, options = {}) {
|
constructor(sdk, options = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "rgba(255, 0, 0, 0.5)"
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10
|
this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10
|
||||||
this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20
|
this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.center = options.center || {}
|
this.options.center = options.center || {}
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
options.label = options.label || {}
|
options.label = options.label || {}
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
@ -60,8 +94,8 @@ class EllipseObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -229,32 +263,32 @@ class EllipseObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
this.entity.polyline.width = this.lineWidth
|
this.entity.polyline.width = this.lineWidth
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.color = c
|
this.color = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -266,25 +300,25 @@ class EllipseObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -296,10 +330,10 @@ class EllipseObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
||||||
item.value = v
|
item.value = this.options.line.width
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +381,7 @@ class EllipseObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -381,7 +415,7 @@ class EllipseObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -481,7 +515,7 @@ class EllipseObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -492,7 +526,7 @@ class EllipseObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -508,7 +542,7 @@ class EllipseObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -534,7 +568,7 @@ class EllipseObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1161,7 +1195,7 @@ class EllipseObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('circle-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('circle-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1175,7 +1209,7 @@ class EllipseObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1189,7 +1223,7 @@ class EllipseObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1203,7 +1237,7 @@ class EllipseObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labellineColorPicker = new ewPlugins('colorpicker', {
|
let labellineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1217,7 +1251,7 @@ class EllipseObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1231,7 +1265,7 @@ class EllipseObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -13,6 +13,15 @@ class Explosion extends Base {
|
|||||||
* @description 爆炸
|
* @description 爆炸
|
||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 爆炸属性
|
* @param options {object} 爆炸属性
|
||||||
|
* @param options.id {string} 唯一标识
|
||||||
|
* @param options.show=true {boolean} 显隐
|
||||||
|
* @param options.name {string} 名称
|
||||||
|
* @param {object} options.position={} 位置
|
||||||
|
* @param {number} options.position.lng 经度
|
||||||
|
* @param {number} options.position.lat 纬度
|
||||||
|
* @param {number} options.position.alt 高度
|
||||||
|
* @param options.scaleByDistance=true {boolean} 是否开启跟随视野缩放
|
||||||
|
* @param options.size=80 {number} 大小(爆炸范围)
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
|
|||||||
@ -40,14 +40,22 @@ class FlowLine extends Base {
|
|||||||
this.options.duration = options.duration || 10.0
|
this.options.duration = options.duration || 10.0
|
||||||
this.options.color = options.color || "rgba(255,255,255,1)"
|
this.options.color = options.color || "rgba(255,255,255,1)"
|
||||||
this.options.lineBackAlpha = options.lineBackAlpha || 0.05
|
this.options.lineBackAlpha = options.lineBackAlpha || 0.05
|
||||||
|
this.options.positions = options.positions || []
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.Dialog = _Dialog
|
this.Dialog = _Dialog
|
||||||
this._EventBinding = new EventBinding()
|
this._EventBinding = new EventBinding()
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
this.positionArea = []
|
this.positionArea = []
|
||||||
this.positions = []
|
this.positions = []
|
||||||
|
if (!this.options.positions || this.options.positions.length < 3) {
|
||||||
|
this._error = '最少需要绘制三个坐标!'
|
||||||
|
console.warn(this._error)
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.sdk.addIncetance(this.options.id, this)
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
FlowLine.create(this)
|
// FlowLine.create(this)
|
||||||
|
FlowLine.drawLine(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建水面
|
// 创建水面
|
||||||
@ -68,6 +76,13 @@ class FlowLine extends Base {
|
|||||||
that.edit(true)
|
that.edit(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
static drawLine(that) {
|
||||||
|
that.positionArea = that.options.positions
|
||||||
|
let posis = that.getRandomPointsInCesiumPolygon(that.options.positions, that.options.pointNumber)
|
||||||
|
that.positions = posis
|
||||||
|
that.getLine(that, posis)
|
||||||
|
// that.edit(true)
|
||||||
|
}
|
||||||
getRandomPointsInCesiumPolygon(positions, count) {
|
getRandomPointsInCesiumPolygon(positions, count) {
|
||||||
let lons = [], lats = [], posi = []
|
let lons = [], lats = [], posi = []
|
||||||
positions.forEach(item => {
|
positions.forEach(item => {
|
||||||
@ -80,6 +95,7 @@ class FlowLine extends Base {
|
|||||||
const minLat = Math.min(...lats), maxLat = Math.max(...lats);
|
const minLat = Math.min(...lats), maxLat = Math.max(...lats);
|
||||||
|
|
||||||
const points = [];
|
const points = [];
|
||||||
|
let that = this
|
||||||
while (points.length < count) {
|
while (points.length < count) {
|
||||||
const lon = minLon + Math.random() * (maxLon - minLon);
|
const lon = minLon + Math.random() * (maxLon - minLon);
|
||||||
const lat = minLat + Math.random() * (maxLat - minLat);
|
const lat = minLat + Math.random() * (maxLat - minLat);
|
||||||
@ -91,9 +107,14 @@ class FlowLine extends Base {
|
|||||||
|
|
||||||
const isInside = turf.booleanPointInPolygon(point, polygon);
|
const isInside = turf.booleanPointInPolygon(point, polygon);
|
||||||
if (isInside) {
|
if (isInside) {
|
||||||
|
let posi = Cesium.Cartesian3.fromDegrees(lon, lat);
|
||||||
|
const cartographic = that.viewer.scene.globe.ellipsoid.cartesianToCartographic(posi);
|
||||||
|
const height = cartographic.height;
|
||||||
|
|
||||||
points.push([
|
points.push([
|
||||||
lon,
|
lon,
|
||||||
lat
|
lat,
|
||||||
|
height
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,15 +138,17 @@ class FlowLine extends Base {
|
|||||||
positions.forEach((item, index) => {
|
positions.forEach((item, index) => {
|
||||||
let point = item
|
let point = item
|
||||||
//根据点设置起始点位置
|
//根据点设置起始点位置
|
||||||
let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
|
// let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
|
||||||
|
let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], point[2])
|
||||||
//根据点设置结束点位置
|
//根据点设置结束点位置
|
||||||
let end = Cesium.Cartesian3.fromDegrees(point[0], point[1], that.options.height + Math.random() * that.options.heightDifference)
|
let end = Cesium.Cartesian3.fromDegrees(point[0], point[1], point[2] + that.options.height + Math.random() * that.options.heightDifference)
|
||||||
//创建线
|
//创建线
|
||||||
that.viewer.entities.add({
|
that.viewer.entities.add({
|
||||||
parent: celiangEntity,
|
parent: celiangEntity,
|
||||||
|
id: that.options.id + '-' + new Date().getTime() + index,
|
||||||
polyline: {
|
polyline: {
|
||||||
positions: [start, end],
|
positions: [start, end],
|
||||||
width: 2,
|
width: that.options.width,
|
||||||
// material:Cesium.Color.RED
|
// material:Cesium.Color.RED
|
||||||
material: new Cesium.FlowLineMaterialProperty({
|
material: new Cesium.FlowLineMaterialProperty({
|
||||||
color: that.options.color,
|
color: that.options.color,
|
||||||
@ -154,7 +177,7 @@ class FlowLine extends Base {
|
|||||||
|
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -199,6 +222,17 @@ class FlowLine extends Base {
|
|||||||
this.getLine(this, this.positions)
|
this.getLine(this, this.positions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
get show() {
|
||||||
|
return this.options.show
|
||||||
|
}
|
||||||
|
|
||||||
|
set show(v) {
|
||||||
|
this.options.show = v
|
||||||
|
let entity = this.viewer.entities.getById(this.options.id)
|
||||||
|
if (entity) {
|
||||||
|
entity.show = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get heightDifference() {
|
get heightDifference() {
|
||||||
return this.options.heightDifference
|
return this.options.heightDifference
|
||||||
@ -287,9 +321,9 @@ class FlowLine extends Base {
|
|||||||
this.reset()
|
this.reset()
|
||||||
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
||||||
},
|
},
|
||||||
// removeCallBack: () => {
|
removeCallBack: () => {
|
||||||
// this.Dialog.removeCallBack && this.Dialog.removeCallBack()
|
this.Dialog.removeCallBack && this.Dialog.removeCallBack()
|
||||||
// },
|
},
|
||||||
closeCallBack: () => {
|
closeCallBack: () => {
|
||||||
this.reset()
|
this.reset()
|
||||||
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
||||||
@ -308,7 +342,7 @@ class FlowLine extends Base {
|
|||||||
contentElm.innerHTML = html()
|
contentElm.innerHTML = html()
|
||||||
this._DialogObject.contentAppChild(contentElm)
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let waterColorPicker = new ewPlugins('colorpicker', {
|
let waterColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("flowLine-color")[0],
|
el: contentElm.getElementsByClassName("flowLine-color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -416,7 +450,7 @@ class FlowLine extends Base {
|
|||||||
let a = Cesium.Cartesian3.fromDegrees(
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
this.positions[i][0],
|
this.positions[i][0],
|
||||||
this.positions[i][1],
|
this.positions[i][1],
|
||||||
this.options.height + this.options.heightDifference / 2
|
this.positions[i][2] + this.options.height + this.options.heightDifference / 2
|
||||||
)
|
)
|
||||||
positionArray.push(a.x, a.y, a.z)
|
positionArray.push(a.x, a.y, a.z)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,25 @@ import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Glo
|
|||||||
|
|
||||||
class FlyRoam extends Base {
|
class FlyRoam extends Base {
|
||||||
#clickHandler = undefined
|
#clickHandler = undefined
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
|
* @description 飞行漫游
|
||||||
|
* @param options {object}
|
||||||
|
* @param options.id {string} 标注id
|
||||||
|
* @param options.name {string} 名称
|
||||||
|
* @param options.repeat=0 {number} 重复次数
|
||||||
|
* @param options.points=[]] {array} 视点列表
|
||||||
|
* @param options.points[].position {object} 视点位置
|
||||||
|
* @param options.points[].position.lng {number} 经度
|
||||||
|
* @param options.points[].position.lat {number} 纬度
|
||||||
|
* @param options.points[].position.alt {number} 高度
|
||||||
|
* @param options.points[].orientation {object} 视点方向
|
||||||
|
* @param options.points[].orientation.heading=0 {number} 视点航向角
|
||||||
|
* @param options.points[].orientation.pitch=0 {number} 视点俯仰角
|
||||||
|
* @param options.points[].orientation.roll=0 {number} 视点翻滚角
|
||||||
|
* @param options.points[].duration=0 {number} 持续时间
|
||||||
|
**/
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
this.options.id = options.id || this.randomString()
|
this.options.id = options.id || this.randomString()
|
||||||
@ -162,6 +181,7 @@ class FlyRoam extends Base {
|
|||||||
pitch: viewer.camera.pitch,
|
pitch: viewer.camera.pitch,
|
||||||
roll: viewer.camera.roll
|
roll: viewer.camera.roll
|
||||||
}
|
}
|
||||||
|
this.message({text: '操作成功'})
|
||||||
})
|
})
|
||||||
|
|
||||||
let totalTimeElm = contentElm.querySelector("input[name='totalTime']")
|
let totalTimeElm = contentElm.querySelector("input[name='totalTime']")
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
import { getHost, getToken } from "../../../on";
|
import { getHost, getToken } from "../../../on";
|
||||||
import Base from '../index'
|
import Base from '../index'
|
||||||
import Tools from '../../../Tools'
|
import Tools from '../../../Tools'
|
||||||
|
import { syncSplitData } from "../../../Global/SplitScreen";
|
||||||
|
import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../Global/global'
|
||||||
|
|
||||||
class GeoJson extends Base {
|
class GeoJson extends Base {
|
||||||
@ -27,6 +29,7 @@ class GeoJson extends Base {
|
|||||||
this.primitive = undefined
|
this.primitive = undefined
|
||||||
this.positions = []
|
this.positions = []
|
||||||
|
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +51,27 @@ class GeoJson extends Base {
|
|||||||
return this.options.show
|
return this.options.show
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set show(status) {
|
||||||
|
// let sdkD = get2DSdk().sdkD
|
||||||
|
// if (!this.isShowView || !sdkD) {
|
||||||
|
// this.options.show = status
|
||||||
|
// }
|
||||||
|
// if (this.entity) {
|
||||||
|
// if (!this.showView || this.showView == 3 || !sdkD) {
|
||||||
|
// for (let i = 0; i < this.entity.entities.values.length; i++) {
|
||||||
|
// this.entity.entities.values[i].show = this.options.show
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// for (let i = 0; i < this.entity.entities.values.length; i++) {
|
||||||
|
// this.entity.entities.values[i].show = false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// syncData(this.sdk, this.options.id)
|
||||||
|
// syncSplitData(this.sdk, this.options.id)
|
||||||
|
// this.isShowView = false
|
||||||
|
// }
|
||||||
set show(status) {
|
set show(status) {
|
||||||
this.options.show = status
|
this.options.show = status
|
||||||
if (this.entity) {
|
if (this.entity) {
|
||||||
@ -74,6 +98,7 @@ class GeoJson extends Base {
|
|||||||
})
|
})
|
||||||
let json = await rsp.json()
|
let json = await rsp.json()
|
||||||
this.geojson = json
|
this.geojson = json
|
||||||
|
// this.sdk.addIncetance(this.options.id, this)
|
||||||
return GeoJson.addDataToGlobe(this, json.features)
|
return GeoJson.addDataToGlobe(this, json.features)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class Graffiti extends Draw {
|
|||||||
this.options.color = v
|
this.options.color = v
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -77,7 +77,7 @@ class Graffiti extends Draw {
|
|||||||
contentElm.innerHTML = html()
|
contentElm.innerHTML = html()
|
||||||
that._DialogObject.contentAppChild(contentElm)
|
that._DialogObject.contentAppChild(contentElm)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
|
|||||||
@ -7,13 +7,21 @@ function html() {
|
|||||||
<span class="label">名称</span>
|
<span class="label">名称</span>
|
||||||
<input class="input" maxlength="40" type="text" @model="name">
|
<input class="input" maxlength="40" type="text" @model="name">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col"></div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="custom-divider"></span>
|
<span class="custom-divider"></span>
|
||||||
<div class="div-item">
|
<div class="div-item">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<button class="anchor btn">调整锚点</button>
|
||||||
|
</div>
|
||||||
|
<div class="col mode-box">
|
||||||
|
<span class="label" style="flex: unset;">军标模式</span>
|
||||||
|
<div class="mode"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" mode="0">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<span class="label">旋转角度</span>
|
<span class="label">旋转角度</span>
|
||||||
<input type="range" max="360" min="0" step="0.1" @model="angle">
|
<input type="range" max="360" min="0" step="0.1" @model="angle">
|
||||||
@ -24,16 +32,85 @@ function html() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row" mode="0">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<span class="label">调整大小</span>
|
<span class="label">调整大小</span>
|
||||||
<input type="range" max="99999" min="0" step="0.1" @model="scale">
|
<input type="range" max="40000" min="0" step="0.1" @model="scale">
|
||||||
<div class="input-number input-number-unit-1" style="width: 100px;flex: 0 0 100px;margin-left: 10px;">
|
<div class="input-number input-number-unit-1" style="width: 100px;flex: 0 0 100px;margin-left: 10px;">
|
||||||
<input class="input" type="number" title="" min="0" max="99999" step="0.1" @model="scale">
|
<input class="input" type="number" title="" min="0" max="40000" step="0.1" @model="scale">
|
||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row" mode="1">
|
||||||
|
<div class="col height-mode-box" style="flex: 0 0 155px;margin-right: 10px;">
|
||||||
|
<span class="label" style="flex: 0 0 56px;">高度模式</span>
|
||||||
|
<div class="height-mode"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin: 0 10px;">
|
||||||
|
<div class="height-box" style="display: flex; align-items: center;">
|
||||||
|
<span class="label" style="flex: 0 0 56px;">高度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input height" type="number" title="" min="-9999999" max="999999999">
|
||||||
|
<span class="unit">m</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin-left: 10px;">
|
||||||
|
<span class="label">图标倍数</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" data-min="0.1" max="99" @model="billboardScale">
|
||||||
|
<span class="unit">倍</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" mode="1">
|
||||||
|
<div class="col" style="flex: 0 0 155px;margin-right: 10px;">
|
||||||
|
<span class="label">视野缩放</span>
|
||||||
|
<input class="btn-switch" type="checkbox" @model="billboardScaleByDistance">
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin: 0 10px;">
|
||||||
|
<span class="label">最近距离</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="1" max="99999999" @model="billboardNear">
|
||||||
|
<span class="unit">m</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin-left: 10px;">
|
||||||
|
<span class="label">最远距离</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" min="1" max="99999999" @model="billboardFar">
|
||||||
|
<span class="unit">m</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h4 mode="1">文字设置</h4>
|
||||||
|
<div class="row" mode="1">
|
||||||
|
<div class="col" style="flex: 0 0 80px;margin: 0 10px;">
|
||||||
|
<span class="label" style="flex: none;">显隐</span>
|
||||||
|
<input class="btn-switch" type="checkbox" @model="labelShow">
|
||||||
|
</div>
|
||||||
|
<div class="col font-select-box" style="margin: 0 0px;flex: 0 0 150px;">
|
||||||
|
<span class="label" style="flex: none;">字体选择</span>
|
||||||
|
<div class="input input-select font-select"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin: 0 10px;">
|
||||||
|
<span class="label">文字大小</span>
|
||||||
|
<div class="input-number input-number-unit-2">
|
||||||
|
<input class="input" type="number" title="" min="1" max="99" @model="labelFontSize" style="width: 70px;">
|
||||||
|
<span class="unit">px</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="margin-left: 10px;">
|
||||||
|
<span class="label">文字颜色</span>
|
||||||
|
<div class="labelColor"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="custom-divider"></span>
|
<span class="custom-divider"></span>
|
||||||
`
|
`
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ function html(that) {
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col" style="flex: 5;">
|
<div class="col" style="flex: 5;">
|
||||||
<span class="label">文字内容</span>
|
<span class="label">文字内容</span>
|
||||||
<input class="input" type="text" @model="textValue">
|
<input class="input" type="text" @model="textValue" maxlength="30">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<button class="btn" @click="textPosPick">设置位置</span>
|
<button class="btn" @click="textPosPick">设置位置</span>
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -796,7 +796,7 @@ class GroundSvg extends Base {
|
|||||||
await this._DialogObject.contentAppChild(contentElm)
|
await this._DialogObject.contentAppChild(contentElm)
|
||||||
|
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import { FontLoader } from '../../../../static/3rdparty/three/jsm/loaders/FontLo
|
|||||||
import { TextGeometry } from '../../../../static/3rdparty/three/jsm/geometries/TextGeometry.js';
|
import { TextGeometry } from '../../../../static/3rdparty/three/jsm/geometries/TextGeometry.js';
|
||||||
import * as variable from '../../../../static/3rdparty/three/fonts/FZZongYi-M05S_regular.typeface.json'
|
import * as variable from '../../../../static/3rdparty/three/fonts/FZZongYi-M05S_regular.typeface.json'
|
||||||
import Base from "../index";
|
import Base from "../index";
|
||||||
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
|
|
||||||
class GroundSvg extends Base {
|
class GroundSvg extends Base {
|
||||||
@ -25,7 +26,7 @@ class GroundSvg extends Base {
|
|||||||
* @param options.scale {object} 比例
|
* @param options.scale {object} 比例
|
||||||
* @param options.scale.x=1 {number} x轴比例
|
* @param options.scale.x=1 {number} x轴比例
|
||||||
* @param options.scale.y=1 {number} y轴比例
|
* @param options.scale.y=1 {number} y轴比例
|
||||||
* @param options.url {string} svg图片地址
|
* @param options.url {string} 资源地址
|
||||||
* @param options.flipe {object} 翻转
|
* @param options.flipe {object} 翻转
|
||||||
* @param options.flipe.x=false {boolean} 绕X轴翻转
|
* @param options.flipe.x=false {boolean} 绕X轴翻转
|
||||||
* @param options.flipe.y=false {boolean} 绕Y轴翻转
|
* @param options.flipe.y=false {boolean} 绕Y轴翻转
|
||||||
@ -33,8 +34,31 @@ class GroundSvg extends Base {
|
|||||||
* @param options.position.lng {number} 经度
|
* @param options.position.lng {number} 经度
|
||||||
* @param options.position.lat {number} 纬度
|
* @param options.position.lat {number} 纬度
|
||||||
* @param options.color {string} 颜色
|
* @param options.color {string} 颜色
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.text {object} 文字
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.text.show=true {boolean} 文字
|
||||||
|
* @param options.text.position.lng {number} 经度
|
||||||
|
* @param options.text.position.lat {number} 纬度
|
||||||
|
* @param options.text.position.alt {number} 高度
|
||||||
|
* @param options.text.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.text.color=#ffffff {string} 字体大小
|
||||||
|
* @param options.text.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.text.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.text.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param {object} options.attribute.link={} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
#loadEvent = void 0
|
#loadEvent = void 0
|
||||||
#loaded = false
|
#loaded = false
|
||||||
@ -108,13 +132,19 @@ class GroundSvg extends Base {
|
|||||||
this._isdrag = false
|
this._isdrag = false
|
||||||
this._EventBinding = new EventBinding()
|
this._EventBinding = new EventBinding()
|
||||||
|
|
||||||
|
if(this.sdk.entityMap.get(this.options.id)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.sdk.addIncetance(this.options.id, this)
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
this.picking = true
|
this.picking = true
|
||||||
|
|
||||||
|
|
||||||
if (this.options.show) {
|
if (this.options.show) {
|
||||||
setSplitDirection(0, this.options.id)
|
setSplitDirection(0, this.options.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._entityArray = []
|
||||||
|
|
||||||
this.init()
|
this.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,12 +183,18 @@ class GroundSvg extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
super.show = v
|
if (this.options.text && this.options.text.show) {
|
||||||
if (this.options.text && this.options.text.show && this.text) {
|
if(this.text) {
|
||||||
|
if((!this.showView || this.showView == 3)) {
|
||||||
this.text.show = v
|
this.text.show = v
|
||||||
}
|
}
|
||||||
syncData(this.sdk, this.options.id)
|
else {
|
||||||
syncSplitData(this.sdk, this.options.id)
|
this.text.show = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
super.show = v
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -206,7 +242,7 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -304,7 +340,12 @@ class GroundSvg extends Base {
|
|||||||
set textShow(v) {
|
set textShow(v) {
|
||||||
this.options.text.show = v
|
this.options.text.show = v
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
|
if((!this.showView || this.showView == 3)) {
|
||||||
this.text && (this.text.show = v)
|
this.text && (this.text.show = v)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.text && (this.text.show = false)
|
||||||
|
}
|
||||||
if (this.options.text.position) {
|
if (this.options.text.position) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.options.text.position.alt) {
|
if (this.options.text.position.alt) {
|
||||||
@ -334,7 +375,7 @@ class GroundSvg extends Base {
|
|||||||
this.text && (this.text.color = v)
|
this.text && (this.text.color = v)
|
||||||
if (this._elms.textColor) {
|
if (this._elms.textColor) {
|
||||||
this._elms.textColor.forEach((item, i) => {
|
this._elms.textColor.forEach((item, i) => {
|
||||||
let textColorPicker = new ewPlugins('colorpicker', {
|
let textColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -358,7 +399,10 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
set textFontSize(v) {
|
set textFontSize(v) {
|
||||||
this.options.text.fontSize = v
|
this.options.text.fontSize = v
|
||||||
this.text && (this.text.fontSize = v)
|
if(this.text) {
|
||||||
|
this.text.fontSize = v
|
||||||
|
this.text.pixelOffset = v
|
||||||
|
}
|
||||||
this._elms.textFontSize && this._elms.textFontSize.forEach((item) => {
|
this._elms.textFontSize && this._elms.textFontSize.forEach((item) => {
|
||||||
item.value = v
|
item.value = v
|
||||||
})
|
})
|
||||||
@ -594,12 +638,13 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
let url = this.replaceHost(this.options.url, this.options.host)
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
this.hierarchys = []
|
this.hierarchys = []
|
||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
let geometryArray = []
|
let geometryArray = []
|
||||||
const loader = new SVGLoader();
|
const loader = new SVGLoader();
|
||||||
loader.load(this.options.url, (data) => {
|
loader.load(url, (data) => {
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.entities) {
|
if (!this.sdk || !this.sdk.viewer || !this.sdk.viewer.entities) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -819,8 +864,13 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
for (let i = 0; i < this.hierarchys.length; i++) {
|
for (let i = 0; i < this.hierarchys.length; i++) {
|
||||||
for (let m = 0; m < this.hierarchys[i].length; m++) {
|
for (let m = 0; m < this.hierarchys[i].length; m++) {
|
||||||
|
let id = this.options.id + `-${i}_${m}}`
|
||||||
|
let oldEntity = this.sdk.viewer.entities.getById(id)
|
||||||
|
if(oldEntity) {
|
||||||
|
this.sdk.viewer.entities.remove(oldEntity)
|
||||||
|
}
|
||||||
let entity = this.sdk.viewer.entities.add({
|
let entity = this.sdk.viewer.entities.add({
|
||||||
id: this.options.id + `-${i}_${m}`,
|
id: this.options.id + `-${i}_${m}}`,
|
||||||
show: this.options.show,
|
show: this.options.show,
|
||||||
polygon: {
|
polygon: {
|
||||||
hierarchy: new Cesium.CallbackProperty(() => {
|
hierarchy: new Cesium.CallbackProperty(() => {
|
||||||
@ -853,6 +903,7 @@ class GroundSvg extends Base {
|
|||||||
color: this.geojson.features[i].properties.color
|
color: this.geojson.features[i].properties.color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this._entityArray.push(entity)
|
||||||
this.entity.add(entity)
|
this.entity.add(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -884,11 +935,10 @@ class GroundSvg extends Base {
|
|||||||
text: that.options.text.value,
|
text: that.options.text.value,
|
||||||
fontSize: that.options.text.fontSize,
|
fontSize: that.options.text.fontSize,
|
||||||
color: that.options.text.color,
|
color: that.options.text.color,
|
||||||
pixelOffset: that.options.text.pixelOffset,
|
pixelOffset: that.options.text.fontSize,
|
||||||
backgroundColor: that.options.text.backgroundColor,
|
backgroundColor: that.options.text.backgroundColor,
|
||||||
lineColor: that.options.text.lineColor,
|
lineColor: '#ffffff00',
|
||||||
lineWidth: that.options.text.lineWidth,
|
lineWidth: 0,
|
||||||
pixelOffset: 0,
|
|
||||||
scaleByDistance: that.options.text.scaleByDistance,
|
scaleByDistance: that.options.text.scaleByDistance,
|
||||||
backgroundColor: ['#ffffff00', '#ffffff00'],
|
backgroundColor: ['#ffffff00', '#ffffff00'],
|
||||||
near: that.options.text.near,
|
near: that.options.text.near,
|
||||||
@ -923,7 +973,9 @@ class GroundSvg extends Base {
|
|||||||
this.text && (this.options.text.position = { lng: this.text.position[0], lat: this.text.position[1], alt: this.text.position[2] })
|
this.text && (this.options.text.position = { lng: this.text.position[0], lat: this.text.position[1], alt: this.text.position[2] })
|
||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
let cdoptions = this.deepCopyObj(this.options)
|
||||||
|
cdoptions.host = ''
|
||||||
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(cdoptions)
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
},
|
},
|
||||||
@ -991,7 +1043,7 @@ class GroundSvg extends Base {
|
|||||||
this.attributeType = this.options.attributeType
|
this.attributeType = this.options.attributeType
|
||||||
|
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1006,7 +1058,7 @@ class GroundSvg extends Base {
|
|||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
|
|
||||||
let textColorPicker = new ewPlugins('colorpicker', {
|
let textColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("textColor")[0],
|
el: contentElm.getElementsByClassName("textColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1186,7 +1238,7 @@ class GroundSvg extends Base {
|
|||||||
* @param {boolean} status=false 状态
|
* @param {boolean} status=false 状态
|
||||||
*/
|
*/
|
||||||
drag(status, cd) {
|
drag(status, cd) {
|
||||||
if (!this.#loaded) {
|
if (!this.#loaded || !this.sdk || !this.sdk.viewer) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.ismove = false
|
this.ismove = false
|
||||||
@ -1253,6 +1305,9 @@ class GroundSvg extends Base {
|
|||||||
// 中心点到鼠标的距离
|
// 中心点到鼠标的距离
|
||||||
let distance = turf.rhumbDistance(pointC, point2, options);
|
let distance = turf.rhumbDistance(pointC, point2, options);
|
||||||
|
|
||||||
|
let flag = false
|
||||||
|
let flag2 = false
|
||||||
|
|
||||||
switch (this.pickPoint.id) {
|
switch (this.pickPoint.id) {
|
||||||
case 'svg-control-points_0':
|
case 'svg-control-points_0':
|
||||||
angle = bearing2_0 - bearing1
|
angle = bearing2_0 - bearing1
|
||||||
@ -1264,12 +1319,39 @@ class GroundSvg extends Base {
|
|||||||
bearingH = (((turf.rhumbBearing(pointC, turf.point(controlPoints[2])) + 360) - this.angle) % 360)
|
bearingH = (((turf.rhumbBearing(pointC, turf.point(controlPoints[2])) + 360) - this.angle) % 360)
|
||||||
angleW = bearing2 - bearingW
|
angleW = bearing2 - bearingW
|
||||||
angleH = bearing2 - bearingH
|
angleH = bearing2 - bearingH
|
||||||
|
|
||||||
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
||||||
angleW = angleW + 180
|
angleW = angleW + 180
|
||||||
|
flag=true
|
||||||
}
|
}
|
||||||
if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) {
|
if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) {
|
||||||
angleH = angleH + 180
|
angleH = angleH + 180
|
||||||
|
flag2=true
|
||||||
|
}
|
||||||
|
if(flag && flag2) {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(flag) {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
}
|
||||||
|
else if(flag2) {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radiansW = (Math.PI / 180) * angleW
|
radiansW = (Math.PI / 180) * angleW
|
||||||
@ -1278,8 +1360,8 @@ class GroundSvg extends Base {
|
|||||||
w = (Math.cos(radiansW) * distance) * 2
|
w = (Math.cos(radiansW) * distance) * 2
|
||||||
h = (Math.cos(radiansH) * distance) * 2
|
h = (Math.cos(radiansH) * distance) * 2
|
||||||
// scaleY值
|
// scaleY值
|
||||||
this.scale.x = w / 3.5
|
this.scale.x = Math.abs(w) / 3.5
|
||||||
this.scale.y = h / 3.5
|
this.scale.y = Math.abs(h) / 3.5
|
||||||
break
|
break
|
||||||
case 'svg-control-points_2':
|
case 'svg-control-points_2':
|
||||||
case 'svg-control-points_8':
|
case 'svg-control-points_8':
|
||||||
@ -1288,6 +1370,12 @@ class GroundSvg extends Base {
|
|||||||
|
|
||||||
if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) {
|
if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) {
|
||||||
angleH = angleH + 180
|
angleH = angleH + 180
|
||||||
|
this.pointEntityCollection.values[2].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[8].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.pointEntityCollection.values[2].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[8].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
}
|
}
|
||||||
|
|
||||||
radiansH = (Math.PI / 180) * angleH
|
radiansH = (Math.PI / 180) * angleH
|
||||||
@ -1305,9 +1393,37 @@ class GroundSvg extends Base {
|
|||||||
|
|
||||||
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
||||||
angleW = angleW + 180
|
angleW = angleW + 180
|
||||||
|
flag=true
|
||||||
}
|
}
|
||||||
if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) {
|
if ((angleH > -360 && angleH < -90) || (angleH < 360 && angleH > 90)) {
|
||||||
angleH = angleH + 180
|
angleH = angleH + 180
|
||||||
|
flag2=true
|
||||||
|
}
|
||||||
|
if(flag && flag2) {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(flag) {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
}
|
||||||
|
else if(flag2) {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.pointEntityCollection.values[1].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[3].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
this.pointEntityCollection.values[7].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[9].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radiansW = (Math.PI / 180) * angleW
|
radiansW = (Math.PI / 180) * angleW
|
||||||
@ -1316,8 +1432,8 @@ class GroundSvg extends Base {
|
|||||||
w = (Math.cos(radiansW) * distance) * 2
|
w = (Math.cos(radiansW) * distance) * 2
|
||||||
h = (Math.cos(radiansH) * distance) * 2
|
h = (Math.cos(radiansH) * distance) * 2
|
||||||
// scaleY值
|
// scaleY值
|
||||||
this.scale.x = w / 3.5
|
this.scale.x = Math.abs(w) / 3.5
|
||||||
this.scale.y = h / 3.5
|
this.scale.y = Math.abs(h) / 3.5
|
||||||
break
|
break
|
||||||
case 'svg-control-points_4':
|
case 'svg-control-points_4':
|
||||||
bearingW = (((turf.rhumbBearing(pointC, turf.point(controlPoints[4])) + 360) - this.angle) % 360)
|
bearingW = (((turf.rhumbBearing(pointC, turf.point(controlPoints[4])) + 360) - this.angle) % 360)
|
||||||
@ -1325,6 +1441,12 @@ class GroundSvg extends Base {
|
|||||||
|
|
||||||
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
||||||
angleW = angleW + 180
|
angleW = angleW + 180
|
||||||
|
this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
}
|
}
|
||||||
|
|
||||||
radiansW = (Math.PI / 180) * angleW
|
radiansW = (Math.PI / 180) * angleW
|
||||||
@ -1355,6 +1477,12 @@ class GroundSvg extends Base {
|
|||||||
|
|
||||||
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
if ((angleW > -360 && angleW < -90) || (angleW < 360 && angleW > 90)) {
|
||||||
angleW = angleW + 180
|
angleW = angleW + 180
|
||||||
|
this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.pointEntityCollection.values[4].point.color = Cesium.Color.fromCssColorString('#00ff0a')
|
||||||
|
this.pointEntityCollection.values[6].point.color = Cesium.Color.fromCssColorString('#ff0000')
|
||||||
}
|
}
|
||||||
|
|
||||||
radiansW = (Math.PI / 180) * angleW
|
radiansW = (Math.PI / 180) * angleW
|
||||||
@ -1500,6 +1628,9 @@ class GroundSvg extends Base {
|
|||||||
controlPoints[9] = turf.destination(point, wh, 0 + angle, options).geometry.coordinates
|
controlPoints[9] = turf.destination(point, wh, 0 + angle, options).geometry.coordinates
|
||||||
|
|
||||||
this.controlPoints = controlPoints
|
this.controlPoints = controlPoints
|
||||||
|
if(!this.sdk || !this.sdk.viewer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
for (let i = 0; i < this.controlPoints.length; i++) {
|
for (let i = 0; i < this.controlPoints.length; i++) {
|
||||||
let color = '#00ff0a'
|
let color = '#00ff0a'
|
||||||
if (i === 5) {
|
if (i === 5) {
|
||||||
@ -1988,21 +2119,25 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async remove() {
|
async remove() {
|
||||||
|
this._worker.onmessage = (event) => {}
|
||||||
|
await this.sdk.removeIncetance(this.options.id)
|
||||||
if (!this.entity) {
|
if (!this.entity) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.drag(false)
|
this.drag(false)
|
||||||
|
if(!this.sdk || !this.sdk.viewer) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.sdk.viewer.entities.remove(this.entity)
|
this.sdk.viewer.entities.remove(this.entity)
|
||||||
this.text && this.text.remove()
|
this.text && this.text.remove()
|
||||||
for (let i = this.entity.values.length; i >= 0; i--) {
|
for (let i = this.entity.values.length; i >= 0; i--) {
|
||||||
this.sdk.viewer.entities.remove(this.entity.values[i])
|
this.sdk.viewer.entities.remove(this.entity.values[i])
|
||||||
}
|
}
|
||||||
this.entity = null
|
|
||||||
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this._DialogObject = null
|
this._DialogObject = null
|
||||||
}
|
}
|
||||||
await this.sdk.removeIncetance(this.options.id)
|
|
||||||
await syncData(this.sdk, this.options.id)
|
await syncData(this.sdk, this.options.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2062,6 +2197,59 @@ class GroundSvg extends Base {
|
|||||||
}
|
}
|
||||||
this._update()
|
this._update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async flyTo(options = {}) {
|
||||||
|
if (this._error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setActiveViewer(0)
|
||||||
|
closeRotateAround(this.sdk)
|
||||||
|
closeViewFollow(this.sdk)
|
||||||
|
|
||||||
|
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
|
||||||
|
let orientation = {
|
||||||
|
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
|
||||||
|
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let lng = this.options.customView.relativePosition.lng
|
||||||
|
let lat = this.options.customView.relativePosition.lat
|
||||||
|
let alt = this.options.customView.relativePosition.alt
|
||||||
|
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
|
||||||
|
let position = { ...this.options.position }
|
||||||
|
// 如果没有高度值,则获取紧贴高度计算
|
||||||
|
if (!position.hasOwnProperty('alt')) {
|
||||||
|
position.alt = await this.getClampToHeight(position)
|
||||||
|
}
|
||||||
|
lng = this.options.customView.relativePosition.lng + position.lng
|
||||||
|
lat = this.options.customView.relativePosition.lat + position.lat
|
||||||
|
alt = this.options.customView.relativePosition.alt + position.alt
|
||||||
|
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
this.sdk.viewer.camera.flyTo({
|
||||||
|
destination: destination,
|
||||||
|
orientation: orientation
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let array = []
|
||||||
|
for (let i = 0; i < this.controlPoints.length; i++) {
|
||||||
|
let height = await this.getClampToHeight({lng: this.controlPoints[i][0], lat: this.controlPoints[i][1]})
|
||||||
|
let cartesian = Cesium.Cartesian3.fromDegrees(this.controlPoints[i][0], this.controlPoints[i][1], height)
|
||||||
|
array.push(cartesian.x, cartesian.y, cartesian.z)
|
||||||
|
}
|
||||||
|
let BoundingSphere = Cesium.BoundingSphere.fromVertices(array)
|
||||||
|
|
||||||
|
this.sdk.viewer.camera.flyToBoundingSphere(BoundingSphere, {
|
||||||
|
offset: options.orientation || {
|
||||||
|
heading: Cesium.Math.toRadians(0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(-60.0),
|
||||||
|
roll: Cesium.Math.toRadians(0.0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default GroundSvg
|
export default GroundSvg
|
||||||
@ -14,6 +14,8 @@ import {
|
|||||||
|
|
||||||
class LabelObject extends Base {
|
class LabelObject extends Base {
|
||||||
#updateBillboardImageTimeout
|
#updateBillboardImageTimeout
|
||||||
|
#canvas = document.createElement('canvas')
|
||||||
|
#canvas2 = document.createElement('canvas')
|
||||||
constructor(sdk, options = {}, model) {
|
constructor(sdk, options = {}, model) {
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
this.model = model
|
this.model = model
|
||||||
@ -34,10 +36,10 @@ class LabelObject extends Base {
|
|||||||
}
|
}
|
||||||
this.options.text = textArray.join('\n')
|
this.options.text = textArray.join('\n')
|
||||||
this.options.fontFamily = options.fontFamily || 0
|
this.options.fontFamily = options.fontFamily || 0
|
||||||
this.font = getFontFamily(this.options.fontFamily) || 'Helvetica'
|
this.font = getFontFamily(this.options.fontFamily) || 'SimHei'
|
||||||
this.options.fontSize = options.fontSize || 20
|
this.options.fontSize = options.fontSize || 20
|
||||||
this.options.lineWidth = options.lineWidth || 4
|
this.options.lineWidth = options.lineWidth || 4
|
||||||
this.options.lineColor = options.lineColor || '#fff000'
|
this.options.lineColor = options.lineColor || '#00ffff80'
|
||||||
this.options.color = options.color || '#ffffff'
|
this.options.color = options.color || '#ffffff'
|
||||||
this.options.ground =
|
this.options.ground =
|
||||||
options.ground || options.ground === false ? options.ground : true
|
options.ground || options.ground === false ? options.ground : true
|
||||||
@ -46,8 +48,8 @@ class LabelObject extends Base {
|
|||||||
? options.pixelOffset
|
? options.pixelOffset
|
||||||
: 20
|
: 20
|
||||||
this.options.backgroundColor = options.backgroundColor || [
|
this.options.backgroundColor = options.backgroundColor || [
|
||||||
'#42c6ef',
|
'#00ffff80',
|
||||||
'#42c6ef'
|
'#00ffff80'
|
||||||
]
|
]
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
this.entity
|
this.entity
|
||||||
@ -65,6 +67,11 @@ class LabelObject extends Base {
|
|||||||
}
|
}
|
||||||
this.originalOptions = copyObj(this.options)
|
this.originalOptions = copyObj(this.options)
|
||||||
|
|
||||||
|
let id = this.options.id + '-label'
|
||||||
|
let oldEntity = this.sdk.viewer.entities.getById(id)
|
||||||
|
if (oldEntity) {
|
||||||
|
this.sdk.viewer.entities.remove(oldEntity)
|
||||||
|
}
|
||||||
this.entity = this.sdk.viewer.entities.add({
|
this.entity = this.sdk.viewer.entities.add({
|
||||||
show: this.options.show,
|
show: this.options.show,
|
||||||
id: this.options.id + '-label',
|
id: this.options.id + '-label',
|
||||||
@ -224,31 +231,27 @@ class LabelObject extends Base {
|
|||||||
if (this.model.customScale.z > scale) {
|
if (this.model.customScale.z > scale) {
|
||||||
scale = this.model.customScale.z
|
scale = this.model.customScale.z
|
||||||
}
|
}
|
||||||
|
let pos = this.cartesian3Towgs84(this.model.position, this.sdk.viewer)
|
||||||
let point1 = Cesium.Cartesian3.fromDegrees(
|
let point1 = Cesium.Cartesian3.fromDegrees(
|
||||||
this.options.position[0],
|
pos.lng,
|
||||||
this.options.position[1],
|
pos.lat,
|
||||||
this.options.position[2] +
|
pos.alt +
|
||||||
(this.model.originalBoundingSphereRadius || 1) *
|
(this.model.originalBoundingSphereRadius || 1) *
|
||||||
2 *
|
2 *
|
||||||
(scale || 0.01)
|
(scale || 0.01)
|
||||||
)
|
)
|
||||||
// 点2的位置,也使用经纬高表示
|
// 计算该点在椭球面上的法线方向(垂直于地面的方向)
|
||||||
let point2 = Cesium.Cartesian3.fromDegrees(
|
const ellipsoid = Cesium.Ellipsoid.WGS84;
|
||||||
this.options.position[0],
|
const normal = ellipsoid.geodeticSurfaceNormal(point1);
|
||||||
this.options.position[1],
|
let c = Cesium.Cartesian3.normalize(normal, normal)
|
||||||
this.options.position[2] -
|
const direction = Cesium.Cartesian3.multiplyByScalar(
|
||||||
(this.model.originalBoundingSphereRadius || 1) *
|
c,
|
||||||
2 *
|
-1,
|
||||||
(scale || 0.01)
|
new Cesium.Cartesian3() // 用于存储结果的新对象
|
||||||
)
|
);
|
||||||
let direction = Cesium.Cartesian3.subtract(
|
let ray = new Cesium.Ray(point1, direction)
|
||||||
point2,
|
|
||||||
point1,
|
|
||||||
new Cesium.Cartesian3()
|
|
||||||
)
|
|
||||||
let c = Cesium.Cartesian3.normalize(direction, direction)
|
|
||||||
let ray = new Cesium.Ray(point1, c)
|
|
||||||
let pickedObjects = this.viewer.scene.drillPickFromRay(ray, 5)
|
let pickedObjects = this.viewer.scene.drillPickFromRay(ray, 5)
|
||||||
|
|
||||||
for (let i = 0; i < pickedObjects.length; i++) {
|
for (let i = 0; i < pickedObjects.length; i++) {
|
||||||
if (
|
if (
|
||||||
pickedObjects[i].object &&
|
pickedObjects[i].object &&
|
||||||
@ -407,7 +410,7 @@ class LabelObject extends Base {
|
|||||||
|
|
||||||
set fontFamily(v) {
|
set fontFamily(v) {
|
||||||
this.options.fontFamily = v || 0
|
this.options.fontFamily = v || 0
|
||||||
this.font = getFontFamily(this.options.fontFamily) || 'Helvetica'
|
this.font = getFontFamily(this.options.fontFamily) || 'SimHei'
|
||||||
this.updateBillboardImage()
|
this.updateBillboardImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +418,7 @@ class LabelObject extends Base {
|
|||||||
return this.options.lineWidth
|
return this.options.lineWidth
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.lineWidth = Number(v)
|
this.options.lineWidth = ((Number(v) || Number(v) === 0) ? Number(v) : 4)
|
||||||
if (!this.entity) {
|
if (!this.entity) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -433,6 +436,7 @@ class LabelObject extends Base {
|
|||||||
this.updateBillboardImage()
|
this.updateBillboardImage()
|
||||||
}
|
}
|
||||||
updateBillboardImage() {
|
updateBillboardImage() {
|
||||||
|
// this.entity.billboard.image = this.getcanvas()
|
||||||
clearTimeout(this.#updateBillboardImageTimeout)
|
clearTimeout(this.#updateBillboardImageTimeout)
|
||||||
this.#updateBillboardImageTimeout = setTimeout(() => {
|
this.#updateBillboardImageTimeout = setTimeout(() => {
|
||||||
clearTimeout(this.#updateBillboardImageTimeout)
|
clearTimeout(this.#updateBillboardImageTimeout)
|
||||||
@ -443,7 +447,7 @@ class LabelObject extends Base {
|
|||||||
return this.options.pixelOffset
|
return this.options.pixelOffset
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.lineColor = v
|
this.options.lineColor = v || '#00ffff80'
|
||||||
if (!this.entity) {
|
if (!this.entity) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -484,9 +488,8 @@ class LabelObject extends Base {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
getcanvas() {
|
getcanvas() {
|
||||||
const canvas = document.createElement('canvas')
|
const ctx = this.#canvas.getContext('2d')
|
||||||
const ctx = canvas.getContext('2d')
|
ctx.clearRect(0, 0, this.#canvas.width, this.#canvas.height);
|
||||||
|
|
||||||
ctx.font = this.options.fontSize + 'px ' + this.font
|
ctx.font = this.options.fontSize + 'px ' + this.font
|
||||||
let texts = this.options.text.split('\n')
|
let texts = this.options.text.split('\n')
|
||||||
let canvasWidth = 0
|
let canvasWidth = 0
|
||||||
@ -504,9 +507,8 @@ class LabelObject extends Base {
|
|||||||
if (canvasWidth < this.options.lineWidth) {
|
if (canvasWidth < this.options.lineWidth) {
|
||||||
canvasWidth = this.options.lineWidth
|
canvasWidth = this.options.lineWidth
|
||||||
}
|
}
|
||||||
canvas.width = canvasWidth
|
this.#canvas.width = canvasWidth
|
||||||
|
this.#canvas.height = this.options.pixelOffset + canvasHeight
|
||||||
canvas.height = this.options.pixelOffset + canvasHeight
|
|
||||||
const linearGradient = ctx.createLinearGradient(
|
const linearGradient = ctx.createLinearGradient(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -553,15 +555,14 @@ class LabelObject extends Base {
|
|||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
ctx.closePath()
|
ctx.closePath()
|
||||||
|
|
||||||
const canvas2 = document.createElement('canvas')
|
const ctx2 = this.#canvas2.getContext('2d')
|
||||||
const ctx2 = canvas2.getContext('2d')
|
this.#canvas2.width = this.#canvas.width + 10
|
||||||
canvas2.width = canvas.width + 10
|
this.#canvas2.height = this.#canvas.height + 10
|
||||||
canvas2.height = canvas.height + 10
|
ctx2.drawImage(this.#canvas, 5, 5);
|
||||||
ctx2.drawImage(canvas, 5, 5);
|
|
||||||
|
|
||||||
// const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
// const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
// ctx.putImageData(imageData, 40, 40);
|
// ctx.putImageData(imageData, 40, 40);
|
||||||
return canvas2
|
return this.#canvas2.toDataURL("image/png")
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
|||||||
466
src/Obj/Base/LabelObject2/index.js
Normal file
466
src/Obj/Base/LabelObject2/index.js
Normal file
@ -0,0 +1,466 @@
|
|||||||
|
/**
|
||||||
|
* 标注
|
||||||
|
*/
|
||||||
|
import Base from '../index'
|
||||||
|
import MouseEvent from '../../../Event/index'
|
||||||
|
import {
|
||||||
|
getGroundCover
|
||||||
|
} from '../../../Global/global'
|
||||||
|
import { getFontFamily } from '../../Element/fontSelect'
|
||||||
|
import {
|
||||||
|
addCluster,
|
||||||
|
remove_entity_from_cluster
|
||||||
|
} from '../../../Global/cluster/cluster'
|
||||||
|
|
||||||
|
class LabelObject extends Base {
|
||||||
|
constructor(sdk, options = {}, model) {
|
||||||
|
super(sdk, options)
|
||||||
|
this.model = model
|
||||||
|
this.options.near = options.near || options.near === 0 ? options.near : 2000
|
||||||
|
this.options.far = options.far || options.far === 0 ? options.far : 100000
|
||||||
|
this.options.scaleByDistance = options.scaleByDistance || false
|
||||||
|
this.options.show =
|
||||||
|
options.show || options.show === false ? options.show : true
|
||||||
|
this.options.text = options.text
|
||||||
|
let textArray = this.options.text.split('\n')
|
||||||
|
for (let i = 0; i < textArray.length; i++) {
|
||||||
|
if (textArray[i].length > 40) {
|
||||||
|
textArray[i] = textArray[i].slice(0, 40 - textArray[i].length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (textArray.length > 10) {
|
||||||
|
textArray.splice(10 - textArray.length)
|
||||||
|
}
|
||||||
|
this.options.text = textArray.join('\n')
|
||||||
|
this.options.fontFamily = options.fontFamily || 0
|
||||||
|
this.font = getFontFamily(this.options.fontFamily) || 'SimHei'
|
||||||
|
this.options.fontSize = options.fontSize || 20
|
||||||
|
this.options.lineColor = options.lineColor || '#00ffff80'
|
||||||
|
this.options.color = options.color || '#ffffff'
|
||||||
|
this.options.ground =
|
||||||
|
options.ground || options.ground === false ? options.ground : true
|
||||||
|
this.options.pixelOffset =
|
||||||
|
options.pixelOffset || options.pixelOffset === 0
|
||||||
|
? options.pixelOffset
|
||||||
|
: 20
|
||||||
|
this.options.backgroundColor = options.backgroundColor || [
|
||||||
|
'#00ffff80',
|
||||||
|
'#00ffff80'
|
||||||
|
]
|
||||||
|
this.event = new MouseEvent(this.sdk)
|
||||||
|
this.entity
|
||||||
|
this.create(this.options.position)
|
||||||
|
this.picking = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async create() {
|
||||||
|
let _this = this
|
||||||
|
if (!this.options.position[2] && this.options.position[2] !== 0) {
|
||||||
|
this.options.position[2] = await this.getClampToHeight({
|
||||||
|
lng: this.options.position[0],
|
||||||
|
lat: this.options.position[1]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.originalOptions = copyObj(this.options)
|
||||||
|
|
||||||
|
let id = this.options.id + '-label'
|
||||||
|
let oldEntity = this.sdk.viewer.entities.getById(id)
|
||||||
|
if(oldEntity) {
|
||||||
|
this.sdk.viewer.entities.remove(oldEntity)
|
||||||
|
}
|
||||||
|
this.entity = this.sdk.viewer.entities.add({
|
||||||
|
show: this.options.show,
|
||||||
|
id: this.options.id + '-label',
|
||||||
|
position: new Cesium.CallbackProperty(function () {
|
||||||
|
if (_this.model) {
|
||||||
|
// return Cesium.Cartesian3.fromDegrees(_this.options.position[0], _this.options.position[1], _this.model.originalBoundingSphereRadius*2*_this.model.customScale.z + _this.options.position[2])
|
||||||
|
if (_this.model.isMove) {
|
||||||
|
let scale = _this.model.customScale.x
|
||||||
|
if (_this.model.customScale.y > scale) {
|
||||||
|
scale = _this.model.customScale.y
|
||||||
|
}
|
||||||
|
if (_this.model.customScale.z > scale) {
|
||||||
|
scale = _this.model.customScale.z
|
||||||
|
}
|
||||||
|
let point1 = Cesium.Cartesian3.fromDegrees(
|
||||||
|
_this.options.position[0],
|
||||||
|
_this.options.position[1],
|
||||||
|
_this.options.position[2] +
|
||||||
|
(_this.model.originalBoundingSphereRadius || 1) *
|
||||||
|
2 *
|
||||||
|
(scale || 0.01)
|
||||||
|
)
|
||||||
|
// 点2的位置,也使用经纬高表示
|
||||||
|
let point2 = Cesium.Cartesian3.fromDegrees(
|
||||||
|
_this.options.position[0],
|
||||||
|
_this.options.position[1],
|
||||||
|
_this.options.position[2] -
|
||||||
|
(_this.model.originalBoundingSphereRadius || 1) *
|
||||||
|
2 *
|
||||||
|
(scale || 0.01)
|
||||||
|
)
|
||||||
|
let direction = Cesium.Cartesian3.subtract(
|
||||||
|
point2,
|
||||||
|
point1,
|
||||||
|
new Cesium.Cartesian3()
|
||||||
|
)
|
||||||
|
let c = Cesium.Cartesian3.normalize(direction, direction)
|
||||||
|
let ray = new Cesium.Ray(point1, c)
|
||||||
|
let pickedObjects = _this.viewer.scene.drillPickFromRay(ray, 5)
|
||||||
|
for (let i = 0; i < pickedObjects.length; i++) {
|
||||||
|
if (
|
||||||
|
pickedObjects[i].object &&
|
||||||
|
pickedObjects[i].object.id &&
|
||||||
|
pickedObjects[i].object.id === _this.model.id
|
||||||
|
) {
|
||||||
|
let pos84 = _this.cartesian3Towgs84(pickedObjects[i].position, _this.sdk.viewer)
|
||||||
|
_this.options.position[0] = pos84.lng
|
||||||
|
_this.options.position[1] = pos84.lat
|
||||||
|
_this.options.position[2] = pos84.alt
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Cesium.Cartesian3.fromDegrees(
|
||||||
|
_this.options.position[0],
|
||||||
|
_this.options.position[1],
|
||||||
|
_this.options.position[2]
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return Cesium.Cartesian3.fromDegrees(..._this.options.position)
|
||||||
|
}
|
||||||
|
}, false),
|
||||||
|
// billboard: {
|
||||||
|
// image: this.getcanvas(),
|
||||||
|
// verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
// disableDepthTestDistance: new Cesium.CallbackProperty(function () {
|
||||||
|
// return getGroundCover() ? undefined : Number.POSITIVE_INFINITY
|
||||||
|
// }, false),
|
||||||
|
// scaleByDistance: this.options.scaleByDistance
|
||||||
|
// ? new Cesium.NearFarScalar(this.options.near, 1, this.options.far, 0)
|
||||||
|
// : undefined,
|
||||||
|
// pixelOffsetScaleByDistance: this.options.scaleByDistance
|
||||||
|
// ? new Cesium.NearFarScalar(this.options.near, 1, this.options.far, 0)
|
||||||
|
// : undefined
|
||||||
|
// },
|
||||||
|
label: {
|
||||||
|
text: new Cesium.CallbackProperty(function () {
|
||||||
|
return _this.options.text
|
||||||
|
}, false),
|
||||||
|
font: this.options.fontSize + "px " + this.font,
|
||||||
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
disableDepthTestDistance: new Cesium.CallbackProperty(function () {
|
||||||
|
return getGroundCover() ? undefined : Number.POSITIVE_INFINITY
|
||||||
|
}, false),
|
||||||
|
scaleByDistance: this.options.scaleByDistance
|
||||||
|
? new Cesium.NearFarScalar(this.options.near, 1, this.options.far, 0)
|
||||||
|
: undefined,
|
||||||
|
pixelOffsetScaleByDistance: this.options.scaleByDistance
|
||||||
|
? new Cesium.NearFarScalar(this.options.near, 1, this.options.far, 0)
|
||||||
|
: undefined,
|
||||||
|
fillColor: Cesium.Color.fromCssColorString(this.options.color),
|
||||||
|
backgroundColor: Cesium.Color.fromCssColorString('#6e6e6e'),
|
||||||
|
backgroundPadding: new Cesium.Cartesian2(10, 10),
|
||||||
|
showBackground: true,
|
||||||
|
outlineWidth: 0,
|
||||||
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
get position() {
|
||||||
|
return this.options.position
|
||||||
|
}
|
||||||
|
set position(v) {
|
||||||
|
// console.log(v)
|
||||||
|
this.options.position = v
|
||||||
|
if (!v[2] && v[2] !== 0) {
|
||||||
|
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||||
|
this.getClampToHeight({
|
||||||
|
lng: v[0],
|
||||||
|
lat: v[1]
|
||||||
|
}, objectsToExclude).then(height => {
|
||||||
|
v[2] = height
|
||||||
|
this.options.position = [...v]
|
||||||
|
})
|
||||||
|
// let point1 = Cesium.Cartesian3.fromDegrees(this.options.position[0], this.options.position[1], 0);
|
||||||
|
// let point2 = Cesium.Cartesian3.fromDegrees(this.options.position[0], this.options.position[1], 10000000);
|
||||||
|
// let direction = Cesium.Cartesian3.subtract(point2, point1, new Cesium.Cartesian3());
|
||||||
|
// let c = Cesium.Cartesian3.normalize(direction, direction);
|
||||||
|
// let ray = new Cesium.Ray(point1, c);
|
||||||
|
// let r = {}
|
||||||
|
// let pickedObjects = this.sdk.viewer.scene.drillPickFromRay(ray);
|
||||||
|
// for (let i = 0; i < pickedObjects.length; i++) {
|
||||||
|
// if (pickedObjects[i].position) {
|
||||||
|
// r = pickedObjects[i]
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (r && r.position) {
|
||||||
|
// this.options.position[2] = this.cartesian3Towgs84(r.position, this.sdk.viewer).alt
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// try {
|
||||||
|
// let promise = Cesium.sampleTerrainMostDetailed(this.sdk.viewer.terrainProvider, [Cesium.Cartographic.fromDegrees(this.options.position[0], this.options.position[1])]);
|
||||||
|
// promise.then((p) => {
|
||||||
|
// this.options.position[2] = p[0].height
|
||||||
|
// }).catch((e)=>{
|
||||||
|
// })
|
||||||
|
// } catch (error) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
this.options.position = [...v]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get show() {
|
||||||
|
return this.options.show
|
||||||
|
}
|
||||||
|
set show(v) {
|
||||||
|
this.options.show = v
|
||||||
|
if (!this.entity) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.entity.show = v
|
||||||
|
if (this.model) {
|
||||||
|
// return Cesium.Cartesian3.fromDegrees(this.options.position[0], this.options.position[1], this.model.originalBoundingSphereRadius*2*this.model.customScale.z + this.options.position[2])
|
||||||
|
let scale = this.model.customScale.x
|
||||||
|
if (this.model.customScale.y > scale) {
|
||||||
|
scale = this.model.customScale.y
|
||||||
|
}
|
||||||
|
if (this.model.customScale.z > scale) {
|
||||||
|
scale = this.model.customScale.z
|
||||||
|
}
|
||||||
|
let point1 = Cesium.Cartesian3.fromDegrees(
|
||||||
|
this.options.position[0],
|
||||||
|
this.options.position[1],
|
||||||
|
this.options.position[2] +
|
||||||
|
(this.model.originalBoundingSphereRadius || 1) *
|
||||||
|
2 *
|
||||||
|
(scale || 0.01)
|
||||||
|
)
|
||||||
|
// 点2的位置,也使用经纬高表示
|
||||||
|
let point2 = Cesium.Cartesian3.fromDegrees(
|
||||||
|
this.options.position[0],
|
||||||
|
this.options.position[1],
|
||||||
|
this.options.position[2] -
|
||||||
|
(this.model.originalBoundingSphereRadius || 1) *
|
||||||
|
2 *
|
||||||
|
(scale || 0.01)
|
||||||
|
)
|
||||||
|
let direction = Cesium.Cartesian3.subtract(
|
||||||
|
point2,
|
||||||
|
point1,
|
||||||
|
new Cesium.Cartesian3()
|
||||||
|
)
|
||||||
|
let c = Cesium.Cartesian3.normalize(direction, direction)
|
||||||
|
let ray = new Cesium.Ray(point1, c)
|
||||||
|
let pickedObjects = this.viewer.scene.drillPickFromRay(ray, 5)
|
||||||
|
for (let i = 0; i < pickedObjects.length; i++) {
|
||||||
|
if (
|
||||||
|
pickedObjects[i].object &&
|
||||||
|
pickedObjects[i].object.id &&
|
||||||
|
pickedObjects[i].object.id === this.model.id
|
||||||
|
) {
|
||||||
|
let pos84 = this.cartesian3Towgs84(pickedObjects[i].position, this.sdk.viewer)
|
||||||
|
this.options.position[0] = pos84.lng
|
||||||
|
this.options.position[1] = pos84.lat
|
||||||
|
this.options.position[2] = pos84.alt
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.options.ground) {
|
||||||
|
let objectsToExclude = [...this.sdk.viewer.entities.values]
|
||||||
|
this.getClampToHeight({
|
||||||
|
lng: this.options.position[0],
|
||||||
|
lat: this.options.position[1]
|
||||||
|
}, objectsToExclude).then(height => {
|
||||||
|
this.options.position[2] = height
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
get text() {
|
||||||
|
return this.options.text
|
||||||
|
}
|
||||||
|
set text(v) {
|
||||||
|
this.options.text = v
|
||||||
|
let textArray = this.options.text.split('\n')
|
||||||
|
for (let i = 0; i < textArray.length; i++) {
|
||||||
|
if (textArray[i].length > 40) {
|
||||||
|
textArray[i] = textArray[i].slice(0, 40 - textArray[i].length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (textArray.length > 10) {
|
||||||
|
textArray.splice(10 - textArray.length)
|
||||||
|
}
|
||||||
|
this.options.text = textArray.join('\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
get color() {
|
||||||
|
return this.options.color
|
||||||
|
}
|
||||||
|
set color(v) {
|
||||||
|
this.options.color = v
|
||||||
|
this.entity.label.fillColor = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
|
}
|
||||||
|
|
||||||
|
get scaleByDistance() {
|
||||||
|
return this.options.scaleByDistance
|
||||||
|
}
|
||||||
|
set scaleByDistance(v) {
|
||||||
|
this.options.scaleByDistance = v
|
||||||
|
if (!this.entity) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.options.scaleByDistance) {
|
||||||
|
this.entity.label.scaleByDistance = new Cesium.NearFarScalar(
|
||||||
|
this.options.near,
|
||||||
|
1,
|
||||||
|
this.options.far,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
this.entity.label.pixelOffsetScaleByDistance = new Cesium.NearFarScalar(
|
||||||
|
this.options.near,
|
||||||
|
1,
|
||||||
|
this.options.far,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.entity.label.scaleByDistance = undefined
|
||||||
|
this.entity.label.pixelOffsetScaleByDistance = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get near() {
|
||||||
|
return this.options.near
|
||||||
|
}
|
||||||
|
set near(v) {
|
||||||
|
let near = v
|
||||||
|
if (near > this.far) {
|
||||||
|
near = this.far
|
||||||
|
}
|
||||||
|
this.options.near = near
|
||||||
|
if (!this.entity) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.options.scaleByDistance) {
|
||||||
|
this.entity.label.scaleByDistance = new Cesium.NearFarScalar(
|
||||||
|
this.options.near,
|
||||||
|
1,
|
||||||
|
this.options.far,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
this.entity.label.pixelOffsetScaleByDistance = new Cesium.NearFarScalar(
|
||||||
|
this.options.near,
|
||||||
|
1,
|
||||||
|
this.options.far,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.entity.label.scaleByDistance = undefined
|
||||||
|
this.entity.label.pixelOffsetScaleByDistance = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get far() {
|
||||||
|
return this.options.far
|
||||||
|
}
|
||||||
|
set far(v) {
|
||||||
|
let far = v
|
||||||
|
if (far < this.near) {
|
||||||
|
far = this.near
|
||||||
|
}
|
||||||
|
this.options.far = far
|
||||||
|
if (!this.entity) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.options.scaleByDistance) {
|
||||||
|
this.entity.label.scaleByDistance = new Cesium.NearFarScalar(
|
||||||
|
this.options.near,
|
||||||
|
1,
|
||||||
|
this.options.far,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
this.entity.label.pixelOffsetScaleByDistance = new Cesium.NearFarScalar(
|
||||||
|
this.options.near,
|
||||||
|
1,
|
||||||
|
this.options.far,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.entity.label.scaleByDistance = undefined
|
||||||
|
this.entity.label.pixelOffsetScaleByDistance = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get fontSize() {
|
||||||
|
return this.options.fontSize
|
||||||
|
}
|
||||||
|
set fontSize(v) {
|
||||||
|
this.options.fontSize = Number(v)
|
||||||
|
if (!this.entity) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.entity.label.font = this.options.fontSize + "px " + this.font
|
||||||
|
}
|
||||||
|
|
||||||
|
get fontFamily() {
|
||||||
|
return this.options.fontFamily
|
||||||
|
}
|
||||||
|
|
||||||
|
set fontFamily(v) {
|
||||||
|
this.options.fontFamily = v || 0
|
||||||
|
this.font = getFontFamily(this.options.fontFamily) || 'SimHei'
|
||||||
|
this.entity.label.font = this.options.fontSize + "px " + this.font
|
||||||
|
}
|
||||||
|
|
||||||
|
get ground() {
|
||||||
|
return this.options.ground
|
||||||
|
}
|
||||||
|
set ground(v) {
|
||||||
|
this.options.ground = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// get backgroundColorStart() {
|
||||||
|
// return this.options.backgroundColor[0]
|
||||||
|
// }
|
||||||
|
// set backgroundColorStart(v) {
|
||||||
|
// this.options.backgroundColor[0] = v
|
||||||
|
// this.entity.billboard.image = this.getcanvas()
|
||||||
|
// }
|
||||||
|
// get backgroundColorEnd() {
|
||||||
|
// return this.options.backgroundColor[1]
|
||||||
|
// }
|
||||||
|
// set backgroundColorEnd(v) {
|
||||||
|
// this.options.backgroundColor[1] = v
|
||||||
|
// this.entity.billboard.image = this.getcanvas()
|
||||||
|
// }
|
||||||
|
|
||||||
|
remove() {
|
||||||
|
this.sdk.viewer.entities.remove(this.entity)
|
||||||
|
this.entity = null
|
||||||
|
}
|
||||||
|
|
||||||
|
flicker() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LabelObject
|
||||||
|
|
||||||
|
const copyObj = (obj = {}) => {
|
||||||
|
//变量先置空
|
||||||
|
let newobj = null
|
||||||
|
|
||||||
|
//判断是否需要继续进行递归
|
||||||
|
if (typeof obj == 'object' && obj !== null) {
|
||||||
|
newobj = obj instanceof Array ? [] : {} //进行下一层递归克隆
|
||||||
|
for (var i in obj) {
|
||||||
|
newobj[i] = copyObj(obj[i])
|
||||||
|
} //如果不是对象直接赋值
|
||||||
|
} else newobj = obj
|
||||||
|
return newobj
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ import EventBinding from './eventBinding'
|
|||||||
import Base from "../../index";
|
import Base from "../../index";
|
||||||
import MouseEvent from '../../../../Event/index'
|
import MouseEvent from '../../../../Event/index'
|
||||||
import { syncPrimitives } from '../../../../Global/MultiViewportMode'
|
import { syncPrimitives } from '../../../../Global/MultiViewportMode'
|
||||||
import { syncData } from '../../../../Global/MultiViewportMode'
|
import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
|
||||||
import MouseTip from '../../../../MouseTip'
|
import MouseTip from '../../../../MouseTip'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
|
||||||
@ -18,9 +18,10 @@ class Flame extends Base {
|
|||||||
* @description 火焰特效
|
* @description 火焰特效
|
||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 粒子属性
|
* @param options {object} 粒子属性
|
||||||
|
* @param options.id {string} 标注id
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.url {string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} 指定 Image、URL或Canvas 的属性
|
* @param options.url {string} 贴图地址
|
||||||
* @param options.startColor="#ff0000" {string} 起始颜色
|
* @param options.startColor="#ff0000" {string} 起始颜色
|
||||||
* @param options.endColor="#fff000" {string} 结束颜色
|
* @param options.endColor="#fff000" {string} 结束颜色
|
||||||
* @param options.startScale=0.5 {number} 初始比例
|
* @param options.startScale=0.5 {number} 初始比例
|
||||||
@ -34,8 +35,15 @@ class Flame extends Base {
|
|||||||
* @param options.lng 经度
|
* @param options.lng 经度
|
||||||
* @param options.lat 纬度
|
* @param options.lat 纬度
|
||||||
* @param options.alt 高度
|
* @param options.alt 高度
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.customView {object} 默认视角
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options, _Dialog = {}) {
|
constructor(sdk, options, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
@ -82,18 +90,34 @@ class Flame extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
|
if (!this.isShowView || !sdkD) {
|
||||||
this.options.show = v
|
this.options.show = v
|
||||||
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
|
||||||
this.entity.show = v
|
|
||||||
}
|
}
|
||||||
|
if (!this.showView || this.showView == 3 || !sdkD) {
|
||||||
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
|
this.entity.show = this.options.show
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = this.options.show
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
|
this.entity.show = false
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this._DialogObject && this._DialogObject.showBtn) {
|
if (this._DialogObject && this._DialogObject.showBtn) {
|
||||||
this._DialogObject.showBtn.checked = v
|
this._DialogObject.showBtn.checked = v
|
||||||
}
|
}
|
||||||
if (this.options.label && this.options.label.show) {
|
|
||||||
this.label.show = v
|
|
||||||
}
|
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
this.isShowView = false
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -245,7 +269,7 @@ class Flame extends Base {
|
|||||||
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.startColor) {
|
if (this._elms.startColor) {
|
||||||
this._elms.startColor.forEach((item, i) => {
|
this._elms.startColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -273,7 +297,7 @@ class Flame extends Base {
|
|||||||
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.endColor) {
|
if (this._elms.endColor) {
|
||||||
this._elms.endColor.forEach((item, i) => {
|
this._elms.endColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -496,7 +520,7 @@ class Flame extends Base {
|
|||||||
contentElm.innerHTML = html()
|
contentElm.innerHTML = html()
|
||||||
this._DialogObject.contentAppChild(contentElm)
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let startColorPicker = new ewPlugins('colorpicker', {
|
let startColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("start_color")[0],
|
el: contentElm.getElementsByClassName("start_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -510,7 +534,7 @@ class Flame extends Base {
|
|||||||
this.startColor = 'rgba(255,255,255,1)'
|
this.startColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let endColorPicker = new ewPlugins('colorpicker', {
|
let endColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("end_color")[0],
|
el: contentElm.getElementsByClassName("end_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { html } from "./_element";
|
|||||||
import EventBinding from './eventBinding'
|
import EventBinding from './eventBinding'
|
||||||
import Base from "../../index";
|
import Base from "../../index";
|
||||||
import MouseEvent from '../../../../Event/index'
|
import MouseEvent from '../../../../Event/index'
|
||||||
import { syncData } from '../../../../Global/MultiViewportMode'
|
import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
|
||||||
import MouseTip from '../../../../MouseTip'
|
import MouseTip from '../../../../MouseTip'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
|
||||||
@ -17,9 +17,10 @@ class Fountain extends Base {
|
|||||||
* @description 喷泉特效
|
* @description 喷泉特效
|
||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 粒子属性
|
* @param options {object} 粒子属性
|
||||||
|
* @param options.id {string} 标注id
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.url {string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} 指定 Image、URL或Canvas 的属性
|
* @param options.url {string} 贴图地址
|
||||||
* @param options.startColor="#c1f7f24d" {string} 起始颜色
|
* @param options.startColor="#c1f7f24d" {string} 起始颜色
|
||||||
* @param options.endColor="#ffffff00" {string} 结束颜色
|
* @param options.endColor="#ffffff00" {string} 结束颜色
|
||||||
* @param options.startScale=1 {number} 初始比例
|
* @param options.startScale=1 {number} 初始比例
|
||||||
@ -30,12 +31,18 @@ class Fountain extends Base {
|
|||||||
* @param options.maximumParticleLife=7 {number} 最大存在时间(秒)
|
* @param options.maximumParticleLife=7 {number} 最大存在时间(秒)
|
||||||
* @param options.emissionRate=20 {number} 发射速率(个/每秒)
|
* @param options.emissionRate=20 {number} 发射速率(个/每秒)
|
||||||
* @param options.particleSize=0.5{number} 粒子尺大小
|
* @param options.particleSize=0.5{number} 粒子尺大小
|
||||||
* @param options.gravity=-3.5{number} 重力值
|
|
||||||
* @param options.lng 经度
|
* @param options.lng 经度
|
||||||
* @param options.lat 纬度
|
* @param options.lat 纬度
|
||||||
* @param options.alt 高度
|
* @param options.alt 高度
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.customView {object} 默认视角
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options, _Dialog = {}) {
|
constructor(sdk, options, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
@ -50,7 +57,7 @@ class Fountain extends Base {
|
|||||||
this.options.maximumSpeed = options.maximumSpeed || 9.5
|
this.options.maximumSpeed = options.maximumSpeed || 9.5
|
||||||
this.options.emissionRate = options.emissionRate || 20
|
this.options.emissionRate = options.emissionRate || 20
|
||||||
this.options.particleSize = options.particleSize || 0.5
|
this.options.particleSize = options.particleSize || 0.5
|
||||||
this.options.gravity = (options.gravity || options.gravity === 0) ? options.gravity : -3.5
|
// this.options.gravity = (options.gravity || options.gravity === 0) ? options.gravity : -3.5
|
||||||
this.options.show = options.show === false ? false : true
|
this.options.show = options.show === false ? false : true
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
this.positionCallBack = null
|
this.positionCallBack = null
|
||||||
@ -83,18 +90,32 @@ class Fountain extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
|
if (!this.isShowView || !sdkD) {
|
||||||
this.options.show = v
|
this.options.show = v
|
||||||
|
}
|
||||||
|
if (!this.showView || this.showView == 3 || !sdkD) {
|
||||||
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
this.entity.show = v
|
this.entity.show = this.options.show
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = this.options.show
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
|
this.entity.show = false
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(this._DialogObject && this._DialogObject.showBtn) {
|
if(this._DialogObject && this._DialogObject.showBtn) {
|
||||||
this._DialogObject.showBtn.checked = v
|
this._DialogObject.showBtn.checked = v
|
||||||
}
|
}
|
||||||
if (this.options.label && this.options.label.show) {
|
|
||||||
this.label.show = v
|
|
||||||
}
|
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
this.isShowView = false
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -269,7 +290,7 @@ class Fountain extends Base {
|
|||||||
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.startColor) {
|
if (this._elms.startColor) {
|
||||||
this._elms.startColor.forEach((item, i) => {
|
this._elms.startColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -297,7 +318,7 @@ class Fountain extends Base {
|
|||||||
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.endColor) {
|
if (this._elms.endColor) {
|
||||||
this._elms.endColor.forEach((item, i) => {
|
this._elms.endColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -520,7 +541,7 @@ class Fountain extends Base {
|
|||||||
contentElm.innerHTML = html()
|
contentElm.innerHTML = html()
|
||||||
this._DialogObject.contentAppChild(contentElm)
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let startColorPicker = new ewPlugins('colorpicker', {
|
let startColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("start_color")[0],
|
el: contentElm.getElementsByClassName("start_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -534,7 +555,7 @@ class Fountain extends Base {
|
|||||||
this.startColor = 'rgba(255,255,255,1)'
|
this.startColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let endColorPicker = new ewPlugins('colorpicker', {
|
let endColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("end_color")[0],
|
el: contentElm.getElementsByClassName("end_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { html, css } from "./_element";
|
|||||||
import EventBinding from './eventBinding'
|
import EventBinding from './eventBinding'
|
||||||
import Base from "../../index";
|
import Base from "../../index";
|
||||||
import MouseEvent from '../../../../Event/index'
|
import MouseEvent from '../../../../Event/index'
|
||||||
import { syncData } from '../../../../Global/MultiViewportMode'
|
import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
|
||||||
import MouseTip from '../../../../MouseTip'
|
import MouseTip from '../../../../MouseTip'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow} from '../../../../Global/global'
|
||||||
@ -17,9 +17,10 @@ class Smoke extends Base {
|
|||||||
* @description 烟雾特效
|
* @description 烟雾特效
|
||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 粒子属性
|
* @param options {object} 粒子属性
|
||||||
|
* @param options.id {string} 标注id
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.url {string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} 指定 Image、URL或Canvas 的属性
|
* @param options.url {string} 贴图地址
|
||||||
* @param options.startColor="#00000000" {string} 起始颜色
|
* @param options.startColor="#00000000" {string} 起始颜色
|
||||||
* @param options.endColor="#0000001a" {string} 结束颜色
|
* @param options.endColor="#0000001a" {string} 结束颜色
|
||||||
* @param options.startScale=0.1 {number} 初始比例
|
* @param options.startScale=0.1 {number} 初始比例
|
||||||
@ -33,8 +34,15 @@ class Smoke extends Base {
|
|||||||
* @param options.lng 经度
|
* @param options.lng 经度
|
||||||
* @param options.lat 纬度
|
* @param options.lat 纬度
|
||||||
* @param options.alt 高度
|
* @param options.alt 高度
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.customView {object} 默认视角
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options, _Dialog = {}) {
|
constructor(sdk, options, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
@ -81,18 +89,32 @@ class Smoke extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
|
if (!this.isShowView || !sdkD) {
|
||||||
this.options.show = v
|
this.options.show = v
|
||||||
|
}
|
||||||
|
if (!this.showView || this.showView == 3 || !sdkD) {
|
||||||
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
this.entity.show = v
|
this.entity.show = this.options.show
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = this.options.show
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
|
this.entity.show = false
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(this._DialogObject && this._DialogObject.showBtn) {
|
if(this._DialogObject && this._DialogObject.showBtn) {
|
||||||
this._DialogObject.showBtn.checked = v
|
this._DialogObject.showBtn.checked = v
|
||||||
}
|
}
|
||||||
if (this.options.label && this.options.label.show) {
|
|
||||||
this.label.show = v
|
|
||||||
}
|
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
this.isShowView = false
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -243,7 +265,7 @@ class Smoke extends Base {
|
|||||||
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.startColor) {
|
if (this._elms.startColor) {
|
||||||
this._elms.startColor.forEach((item, i) => {
|
this._elms.startColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -271,7 +293,7 @@ class Smoke extends Base {
|
|||||||
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.endColor) {
|
if (this._elms.endColor) {
|
||||||
this._elms.endColor.forEach((item, i) => {
|
this._elms.endColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -494,7 +516,7 @@ class Smoke extends Base {
|
|||||||
contentElm.innerHTML = html()
|
contentElm.innerHTML = html()
|
||||||
this._DialogObject.contentAppChild(contentElm)
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let startColorPicker = new ewPlugins('colorpicker', {
|
let startColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("start_color")[0],
|
el: contentElm.getElementsByClassName("start_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -508,7 +530,7 @@ class Smoke extends Base {
|
|||||||
this.startColor = 'rgba(255,255,255,1)'
|
this.startColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let endColorPicker = new ewPlugins('colorpicker', {
|
let endColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("end_color")[0],
|
el: contentElm.getElementsByClassName("end_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import Dialog from '../../../Element/Dialog';
|
|||||||
import { html, css } from "./_element";
|
import { html, css } from "./_element";
|
||||||
import Base from "../../index";
|
import Base from "../../index";
|
||||||
import MouseEvent from '../../../../Event/index'
|
import MouseEvent from '../../../../Event/index'
|
||||||
import { syncData } from '../../../../Global/MultiViewportMode'
|
import { syncData, getSdk as get2DSdk } from '../../../../Global/MultiViewportMode'
|
||||||
import MouseTip from '../../../../MouseTip'
|
import MouseTip from '../../../../MouseTip'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../../Global/SplitScreen'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../../Global/global'
|
||||||
@ -16,9 +16,10 @@ class Spout extends Base {
|
|||||||
* @description 水柱
|
* @description 水柱
|
||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 粒子属性
|
* @param options {object} 粒子属性
|
||||||
|
* @param options.id {string} 标注id
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.url {string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} 指定 Image、URL或Canvas 的属性
|
* @param options.url {string} 贴图地址
|
||||||
* @param options.startColor="#c1f7f2" {string} 起始颜色
|
* @param options.startColor="#c1f7f2" {string} 起始颜色
|
||||||
* @param options.endColor="#ffffff00" {string} 结束颜色
|
* @param options.endColor="#ffffff00" {string} 结束颜色
|
||||||
* @param options.startScale=0.2 {number} 初始比例
|
* @param options.startScale=0.2 {number} 初始比例
|
||||||
@ -28,8 +29,8 @@ class Spout extends Base {
|
|||||||
* @param options.maximumParticleLife=12 {number} 最大存在时间(秒)
|
* @param options.maximumParticleLife=12 {number} 最大存在时间(秒)
|
||||||
* @param options.emissionRate=100 {number} 发射速率(个/每秒)
|
* @param options.emissionRate=100 {number} 发射速率(个/每秒)
|
||||||
* @param options.particleSize=1 {number} 粒子尺大小
|
* @param options.particleSize=1 {number} 粒子尺大小
|
||||||
* @param options.heading 朝向
|
* @param options.heading 航向角
|
||||||
* @param options.pitch 俯仰角度
|
* @param options.pitch 俯仰角
|
||||||
* @param options.start {object} 开始位置
|
* @param options.start {object} 开始位置
|
||||||
* @param options.start.lng 经度
|
* @param options.start.lng 经度
|
||||||
* @param options.start.lat 纬度
|
* @param options.start.lat 纬度
|
||||||
@ -38,8 +39,15 @@ class Spout extends Base {
|
|||||||
* @param options.end.lng 经度
|
* @param options.end.lng 经度
|
||||||
* @param options.end.lat 纬度
|
* @param options.end.lat 纬度
|
||||||
* @param options.end.alt 高度
|
* @param options.end.alt 高度
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.customView {object} 默认视角
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options, _Dialog = {}) {
|
constructor(sdk, options, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
@ -84,18 +92,32 @@ class Spout extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
|
if (!this.isShowView || !sdkD) {
|
||||||
this.options.show = v
|
this.options.show = v
|
||||||
|
}
|
||||||
|
if (!this.showView || this.showView == 3 || !sdkD) {
|
||||||
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
this.entity.show = v
|
this.entity.show = this.options.show
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = this.options.show
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.entity && this.sdk.viewer.camera.positionCartographic.height < 10000000) {
|
||||||
|
this.entity.show = false
|
||||||
|
}
|
||||||
|
if (this.options.label && this.options.label.show) {
|
||||||
|
this.label.show = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(this._DialogObject && this._DialogObject.showBtn) {
|
if(this._DialogObject && this._DialogObject.showBtn) {
|
||||||
this._DialogObject.showBtn.checked = v
|
this._DialogObject.showBtn.checked = v
|
||||||
}
|
}
|
||||||
if (this.options.label && this.options.label.show) {
|
|
||||||
this.label.show = v
|
|
||||||
}
|
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
this.isShowView = false
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -360,7 +382,7 @@ class Spout extends Base {
|
|||||||
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.startColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.startColor) {
|
if (this._elms.startColor) {
|
||||||
this._elms.startColor.forEach((item, i) => {
|
this._elms.startColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -388,7 +410,7 @@ class Spout extends Base {
|
|||||||
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
this.particleSystem.endColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.endColor) {
|
if (this._elms.endColor) {
|
||||||
this._elms.endColor.forEach((item, i) => {
|
this._elms.endColor.forEach((item, i) => {
|
||||||
let picker = new ewPlugins('colorpicker', {
|
let picker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -634,7 +656,7 @@ class Spout extends Base {
|
|||||||
contentElm.innerHTML = html()
|
contentElm.innerHTML = html()
|
||||||
this._DialogObject.contentAppChild(contentElm)
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let startColorPicker = new ewPlugins('colorpicker', {
|
let startColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("start_color")[0],
|
el: contentElm.getElementsByClassName("start_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -648,7 +670,7 @@ class Spout extends Base {
|
|||||||
this.startColor = 'rgba(255,255,255,1)'
|
this.startColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let endColorPicker = new ewPlugins('colorpicker', {
|
let endColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("end_color")[0],
|
el: contentElm.getElementsByClassName("end_color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
|
|||||||
@ -22,25 +22,67 @@ class PincerArrowObject extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @description 双箭头
|
* @description 双箭头
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param {Array.<object>} options.positions 坐标数组 [{lon,lat,alt},...]
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.line {object} 边框
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.line.width=2 {string} 边框宽
|
||||||
|
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||||
|
* @param {Array.<object>} options.positions 必填,经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
||||||
|
* @param options.positions[].lng {number} 经度
|
||||||
|
* @param options.positions[].lat {number} 纬度
|
||||||
|
* @param options.positions[].alt {number} 高度
|
||||||
|
* @param options.spreadState=false {boolean} 动画
|
||||||
|
* @param options.loop=false {loop} 动画重复
|
||||||
|
* @param options.spreadTime=3000 {number} 动画持续时长(毫秒)
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link={} {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "#ff000080"
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.positions = options.positions || []
|
this.options.positions = options.positions || []
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
this.options.height = options.height
|
this.options.height = options.height
|
||||||
this.options.loop = options.loop || false
|
this.options.loop = options.loop || false
|
||||||
@ -62,8 +104,8 @@ class PincerArrowObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -122,31 +164,31 @@ class PincerArrowObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.color = c
|
this.color = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -253,25 +295,25 @@ class PincerArrowObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -283,10 +325,10 @@ class PincerArrowObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
||||||
item.value = v
|
item.value = this.options.line.width
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +376,7 @@ class PincerArrowObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -368,7 +410,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -468,7 +510,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -479,7 +521,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -495,7 +537,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -521,7 +563,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1192,7 +1234,7 @@ class PincerArrowObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('pincer-arrow-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('pincer-arrow-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1206,7 +1248,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1220,7 +1262,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1234,7 +1276,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1248,7 +1290,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1262,7 +1304,7 @@ class PincerArrowObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class PolygonObject extends Base {
|
|||||||
* @param options.id {string} 唯一标识
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param options.line {object} 边框
|
* @param options.line {object} 边框
|
||||||
@ -39,15 +39,15 @@ class PolygonObject extends Base {
|
|||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || '#36c4ff'
|
this.options.color = options.color || 'rgba(255, 0, 0, 0.5)'
|
||||||
this.options.show =
|
this.options.show =
|
||||||
options.show || options.show === false ? options.show : true
|
options.show || options.show === false ? options.show : true
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.positions = options.positions || []
|
this.options.positions = options.positions || []
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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 =
|
||||||
this.options.line.color || 'rgba(155, 155, 124, 0.89)'
|
this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
this.entity
|
this.entity
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
@ -74,8 +74,8 @@ class PolygonObject extends Base {
|
|||||||
options.label.pixelOffset || options.label.pixelOffset === 0
|
options.label.pixelOffset || options.label.pixelOffset === 0
|
||||||
? options.label.pixelOffset
|
? options.label.pixelOffset
|
||||||
: 20,
|
: 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near:
|
near:
|
||||||
options.label.near || options.label.near === 0
|
options.label.near || options.label.near === 0
|
||||||
@ -133,35 +133,35 @@ class PolygonObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
this.heightMode = 0
|
this.heightMode = 0
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false, //是否禁止打开颜色选择器
|
disabled: false, //是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity', //打开颜色选择器动画
|
openPickerAni: 'opacity', //打开颜色选择器动画
|
||||||
sure: c => {
|
sure: c => {
|
||||||
this.color = c
|
this.color = c
|
||||||
}, //点击确认按钮事件回调
|
}, //点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -269,25 +269,25 @@ class PolygonObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false, //是否禁止打开颜色选择器
|
disabled: false, //是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity', //打开颜色选择器动画
|
openPickerAni: 'opacity', //打开颜色选择器动画
|
||||||
sure: c => {
|
sure: c => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
}, //点击确认按钮事件回调
|
}, //点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -299,8 +299,8 @@ class PolygonObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineWidth &&
|
this._elms.lineWidth &&
|
||||||
this._elms.lineWidth.forEach(item => {
|
this._elms.lineWidth.forEach(item => {
|
||||||
item.value = v
|
item.value = v
|
||||||
@ -355,7 +355,7 @@ class PolygonObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
} else {
|
} else {
|
||||||
this.label.show = false
|
this.label.show = false
|
||||||
@ -389,7 +389,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -493,7 +493,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -504,7 +504,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
}, //点击确认按钮事件回调
|
}, //点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -520,7 +520,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -548,7 +548,7 @@ class PolygonObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -1216,7 +1216,6 @@ class PolygonObject extends Base {
|
|||||||
alt: this.label.position[2]
|
alt: this.label.position[2]
|
||||||
}
|
}
|
||||||
this.originalOptions = this.deepCopyObj(this.options)
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
console.log('000000000000',this.options.label.scaleByDistance)
|
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this.Dialog.confirmCallBack &&
|
this.Dialog.confirmCallBack &&
|
||||||
this.Dialog.confirmCallBack(this.originalOptions)
|
this.Dialog.confirmCallBack(this.originalOptions)
|
||||||
@ -1270,7 +1269,7 @@ class PolygonObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('color')[0],
|
el: contentElm.getElementsByClassName('color')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -1284,7 +1283,7 @@ class PolygonObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('lineColor')[0],
|
el: contentElm.getElementsByClassName('lineColor')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -1298,7 +1297,7 @@ class PolygonObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('labelColor')[0],
|
el: contentElm.getElementsByClassName('labelColor')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -1312,7 +1311,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('labelLineColor')[0],
|
el: contentElm.getElementsByClassName('labelLineColor')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -1326,7 +1325,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
} //点击清空按钮事件回调
|
} //点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('labelBackgroundColorStart')[0],
|
el: contentElm.getElementsByClassName('labelBackgroundColorStart')[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1340,7 +1339,7 @@ class PolygonObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('labelBackgroundColorEnd')[0],
|
el: contentElm.getElementsByClassName('labelBackgroundColorEnd')[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -2237,6 +2236,7 @@ class PolygonObject extends Base {
|
|||||||
static nodeEdit(that, cb = () => { }) {
|
static nodeEdit(that, cb = () => { }) {
|
||||||
that.positionEditing = false
|
that.positionEditing = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
let previous = [...that.options.positions]
|
||||||
if (YJ.Measure.GetMeasureStatus()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
cb('上一次测量未结束')
|
cb('上一次测量未结束')
|
||||||
} else {
|
} else {
|
||||||
@ -2299,6 +2299,9 @@ class PolygonObject extends Base {
|
|||||||
that.positions = Cesium.Cartesian3.fromDegreesArray(
|
that.positions = Cesium.Cartesian3.fromDegreesArray(
|
||||||
fromDegreesArray
|
fromDegreesArray
|
||||||
)
|
)
|
||||||
|
that.previous = {
|
||||||
|
positions: [...that.positions]
|
||||||
|
}
|
||||||
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
|
|
||||||
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||||
@ -2390,6 +2393,77 @@ class PolygonObject extends Base {
|
|||||||
if (added) {
|
if (added) {
|
||||||
that.options.positions.splice(selectPoint.index, 1)
|
that.options.positions.splice(selectPoint.index, 1)
|
||||||
}
|
}
|
||||||
|
if (that.options.positions.length < 3) {
|
||||||
|
console.warn('多边形最少需要三个坐标!')
|
||||||
|
window.ELEMENT &&
|
||||||
|
window.ELEMENT.Message({
|
||||||
|
message: '多边形最少需要三个坐标!',
|
||||||
|
type: 'warning',
|
||||||
|
duration: 1500
|
||||||
|
})
|
||||||
|
that.options.positions = [...previous]
|
||||||
|
let positions = that.options.positions
|
||||||
|
let fromDegreesArray = []
|
||||||
|
for (let i = 0; i < positions.length; i++) {
|
||||||
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
|
}
|
||||||
|
that.positions = Cesium.Cartesian3.fromDegreesArray(
|
||||||
|
fromDegreesArray
|
||||||
|
)
|
||||||
|
newpositions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||||
|
that.previous = {
|
||||||
|
positions: [...that.positions]
|
||||||
|
}
|
||||||
|
|
||||||
|
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||||
|
let positions2 = [[]]
|
||||||
|
for (let i = 0; i < that.options.positions.length; i++) {
|
||||||
|
positions2[0].push([
|
||||||
|
that.options.positions[i].lng,
|
||||||
|
that.options.positions[i].lat
|
||||||
|
])
|
||||||
|
}
|
||||||
|
positions2[0].push([
|
||||||
|
that.options.positions[0].lng,
|
||||||
|
that.options.positions[0].lat
|
||||||
|
])
|
||||||
|
let polygon = turf.polygon(positions2)
|
||||||
|
let centroid = turf.centroid(polygon)
|
||||||
|
that
|
||||||
|
.getClampToHeight({
|
||||||
|
lng: centroid.geometry.coordinates[0],
|
||||||
|
lat: centroid.geometry.coordinates[1]
|
||||||
|
}, objectsToExclude)
|
||||||
|
.then(height => {
|
||||||
|
that.label.position = [
|
||||||
|
centroid.geometry.coordinates[0],
|
||||||
|
centroid.geometry.coordinates[1],
|
||||||
|
height
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
that.options.areaByMeter = that.computeArea(that.options.positions)
|
||||||
|
switch (that.options['area-unit']) {
|
||||||
|
case '平方米':
|
||||||
|
that.area = that.options.areaByMeter
|
||||||
|
break
|
||||||
|
case '平方千米':
|
||||||
|
that.area = Number(
|
||||||
|
(that.options.areaByMeter / 1000000).toFixed(8)
|
||||||
|
)
|
||||||
|
break
|
||||||
|
case '亩':
|
||||||
|
that.area = Number(
|
||||||
|
(that.options.areaByMeter / 666.6666667).toFixed(4)
|
||||||
|
)
|
||||||
|
break
|
||||||
|
case '公顷':
|
||||||
|
that.area = Number((that.options.areaByMeter / 10000).toFixed(6))
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
that.area = that.options.areaByMeter
|
||||||
|
}
|
||||||
|
}
|
||||||
cb(null, that.options.positions)
|
cb(null, that.options.positions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ class eventBinding {
|
|||||||
let Event = []
|
let Event = []
|
||||||
let isEvent = false
|
let isEvent = false
|
||||||
let removeName = []
|
let removeName = []
|
||||||
|
let blurEvent = () => { }
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -36,7 +37,8 @@ class eventBinding {
|
|||||||
Event.push((e) => {
|
Event.push((e) => {
|
||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
if (e.target.type == 'number') {
|
if (e.target.type == 'number') {
|
||||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
let str = e.target.value + ''
|
||||||
|
if (e.data != '.' && (e.data != '-' || e.target.value) && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.')) && e.target.value != '0') {
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
if((e.target.max) && value>Number(e.target.max)) {
|
if((e.target.max) && value>Number(e.target.max)) {
|
||||||
value = Number(e.target.max)
|
value = Number(e.target.max)
|
||||||
@ -57,6 +59,22 @@ class eventBinding {
|
|||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
blurEvent = (e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if ((e.target.type == 'number') && (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null)))) {
|
||||||
|
value = Number(value)
|
||||||
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that[m.value] = value
|
||||||
|
}
|
||||||
if(elements[i].nodeName=='IMG') {
|
if(elements[i].nodeName=='IMG') {
|
||||||
elements[i].src = that[m.value]
|
elements[i].src = that[m.value]
|
||||||
}
|
}
|
||||||
@ -114,6 +132,7 @@ class eventBinding {
|
|||||||
Event[t](e)
|
Event[t](e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
elements[i].addEventListener('blur', blurEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,15 +24,50 @@ class PolyhedronObject extends Base {
|
|||||||
* @param options.id {string} 唯一标识
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.color="#0df7f8" {string} 颜色
|
* @param options.color="#ff0000" {string} 颜色
|
||||||
* @param options.height=10 {number} 高
|
* @param options.height=10 {number} 高
|
||||||
* @param {Array.<object>} options.positions 经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
* @param options.areaUnit='平方米' {string} 投影面积单位
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param {Array.<object>} options.positions 必填,经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.positions[].lng {number} 经度
|
||||||
|
* @param options.positions[].lat {number} 纬度
|
||||||
|
* @param options.positions[].alt {number} 高度
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param {object} options.attribute.link={} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.color = options.color || "#0df7f8"
|
this.options.color = options.color || "#ff0000"
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.height = (options.height || options.height === 0) ? options.height : 10
|
this.options.height = (options.height || options.height === 0) ? options.height : 10
|
||||||
if (this.options.height <= 0.01) {
|
if (this.options.height <= 0.01) {
|
||||||
@ -54,8 +89,8 @@ class PolyhedronObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -381,7 +416,7 @@ class PolyhedronObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || '#ff0000'
|
||||||
if(!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if(!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -394,11 +429,11 @@ class PolyhedronObject extends Base {
|
|||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
@ -517,7 +552,7 @@ class PolyhedronObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -551,7 +586,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -651,7 +686,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -662,7 +697,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -678,7 +713,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -704,7 +739,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1105,7 +1140,7 @@ class PolyhedronObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1119,7 +1154,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1133,7 +1168,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1147,7 +1182,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1161,7 +1196,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1433,6 +1468,7 @@ class PolyhedronObject extends Base {
|
|||||||
let originalPosition
|
let originalPosition
|
||||||
|
|
||||||
let added = false
|
let added = false
|
||||||
|
let previous = [...that.options.positions]
|
||||||
let leftEvent = (movement, cartesian) => {
|
let leftEvent = (movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||||
@ -1496,6 +1532,25 @@ class PolyhedronObject extends Base {
|
|||||||
if(added) {
|
if(added) {
|
||||||
that.options.positions.splice(selectPoint.index, 1)
|
that.options.positions.splice(selectPoint.index, 1)
|
||||||
}
|
}
|
||||||
|
if (!that.options.positions || that.options.positions.length < 3) {
|
||||||
|
console.warn('多面体最少需要三个坐标!')
|
||||||
|
window.ELEMENT && window.ELEMENT.Message({
|
||||||
|
message: '多面体最少需要三个坐标!',
|
||||||
|
type: 'warning',
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
that.options.positions = [...previous]
|
||||||
|
}
|
||||||
|
let labelPositions = [[]]
|
||||||
|
for (let i = 0; i < that.options.positions.length; i++) {
|
||||||
|
labelPositions[0].push([that.options.positions[i].lng, that.options.positions[i].lat])
|
||||||
|
}
|
||||||
|
labelPositions[0].push([that.options.positions[0].lng, that.options.positions[0].lat])
|
||||||
|
if (labelPositions[0].length >= 4) {
|
||||||
|
let polygon = turf.polygon(labelPositions);
|
||||||
|
let centroid = turf.centroid(polygon);
|
||||||
|
that.label.position = [centroid.geometry.coordinates[0], centroid.geometry.coordinates[1], that.options.height + that.options.extrudedHeight]
|
||||||
|
}
|
||||||
that.options.areaByMeter = that.computeArea(that.options.positions);
|
that.options.areaByMeter = that.computeArea(that.options.positions);
|
||||||
switch (that.options['area-unit']) {
|
switch (that.options['area-unit']) {
|
||||||
case '平方米':
|
case '平方米':
|
||||||
|
|||||||
@ -53,8 +53,8 @@ class PolyhedronObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -347,7 +347,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.entity.polygon.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polygon.material = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -488,7 +488,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -588,7 +588,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -599,7 +599,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -615,7 +615,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -641,7 +641,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -890,7 +890,7 @@ class PolyhedronObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('polygon-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -904,7 +904,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -918,7 +918,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -932,7 +932,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -946,7 +946,7 @@ class PolyhedronObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -9,22 +9,15 @@ function html(that) {
|
|||||||
<span class="label">名称</span>
|
<span class="label">名称</span>
|
||||||
<input class="input" maxlength="40" type="text" @model="name">
|
<input class="input" maxlength="40" type="text" @model="name">
|
||||||
</div>
|
</div>
|
||||||
<div class="col" style="flex: 0 0 54%;">
|
<div class="col" style="flex: 0 0 56%;">
|
||||||
<div>
|
<div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col input-select-unit-box">
|
<div class="col input-select-unit-box">
|
||||||
<span class="label">原始长度:</span>
|
<div class="input-select-unit"></div>
|
||||||
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length">
|
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length">
|
||||||
<div class="input-select-unit"></div>
|
<div class="input-select-unit"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col input-select-fit-unit-box">
|
|
||||||
<span class="label">拟合长度:</span>
|
|
||||||
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="fitLength">
|
|
||||||
<div class="input-select-fit-unit"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,7 +41,7 @@ function html(that) {
|
|||||||
<span class="unit">m</span>
|
<span class="unit">m</span>
|
||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
<button class="confirm height-confirm" style="margin-left: 5px;">确认</button>
|
<button class="confirm height-confirm" style="margin-left: 5px;">应用</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -72,7 +65,7 @@ function html(that) {
|
|||||||
<span class="label">线条颜色</span>
|
<span class="label">线条颜色</span>
|
||||||
<div class="color"></div>
|
<div class="color"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
<span class="label">线条宽度</span>
|
<span class="label">线条宽度</span>
|
||||||
<div class="input-number input-number-unit-1" style="width: 80px;">
|
<div class="input-number input-number-unit-1" style="width: 80px;">
|
||||||
<input class="input" type="number" title="" min="1" max="999" @model="lineWidth">
|
<input class="input" type="number" title="" min="1" max="999" @model="lineWidth">
|
||||||
@ -80,7 +73,7 @@ function html(that) {
|
|||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col input-select-line-type-box">
|
<div class="col input-select-line-type-box" style="flex: 0 0 37%;">
|
||||||
<span class="label">线条形式</span>
|
<span class="label">线条形式</span>
|
||||||
<div class="input-select-line-type"></div>
|
<div class="input-select-line-type"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -90,11 +83,11 @@ function html(that) {
|
|||||||
<span class="label">首尾相连</span>
|
<span class="label">首尾相连</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="noseToTail">
|
<input class="btn-switch" type="checkbox" @model="noseToTail">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
<span class="label">线段圆滑</span>
|
<span class="label">线段圆滑</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="smooth">
|
<input class="btn-switch" type="checkbox" @model="smooth">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 37%;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -102,7 +95,7 @@ function html(that) {
|
|||||||
<span class="label">线段缓冲</span>
|
<span class="label">线段缓冲</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="extend">
|
<input class="btn-switch" type="checkbox" @model="extend">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
<span class="label">缓冲宽度</span>
|
<span class="label">缓冲宽度</span>
|
||||||
<div class="input-number input-number-unit-1" style="width: 80px;">
|
<div class="input-number input-number-unit-1" style="width: 80px;">
|
||||||
<input class="input" type="number" title="" min="0" data-min="0.01" max="999999" @model="extendWidth">
|
<input class="input" type="number" title="" min="0" data-min="0.01" max="999999" @model="extendWidth">
|
||||||
@ -110,11 +103,32 @@ function html(that) {
|
|||||||
<span class="arrow"></span>
|
<span class="arrow"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col" style="flex: 0 0 37%;">
|
||||||
<span class="label">缓冲颜色</span>
|
<span class="label">缓冲颜色</span>
|
||||||
<div class="extendColor"></div>
|
<div class="extendColor"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row" id="dashTextureDom">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">首尾反向</span>
|
||||||
|
<input class="btn-switch" type="checkbox" @model="rotate">
|
||||||
|
</div>
|
||||||
|
<div class="col" style="flex: 0 0 33%;">
|
||||||
|
<span class="label">流动速率</span>
|
||||||
|
<div class="input-number input-number-unit-1" style="width: 80px;">
|
||||||
|
<input class="input" type="number" title="" min="0" max="999999" step="1" @model="speed">
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" style="flex: 0 0 37%;">
|
||||||
|
<span class="label lineSpace">线条间距</span>
|
||||||
|
<div class="input-number input-number-unit-1 lineSpace" style="width: 80px;">
|
||||||
|
<input class="input" type="number" title="" min="0" max="4.5" step="0.1" @model="space">
|
||||||
|
<span class="unit">倍</span>
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</DIV-cy-tab-pane>
|
</DIV-cy-tab-pane>
|
||||||
<DIV-cy-tab-pane label="标注风格">
|
<DIV-cy-tab-pane label="标注风格">
|
||||||
${labelStyleElm1()}
|
${labelStyleElm1()}
|
||||||
|
|||||||
@ -40,9 +40,11 @@ class eventBinding {
|
|||||||
value = Number(value)
|
value = Number(value)
|
||||||
if ((e.target.max) && value > Number(e.target.max)) {
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
value = Number(e.target.max)
|
value = Number(e.target.max)
|
||||||
|
e.target.value = value
|
||||||
}
|
}
|
||||||
if ((e.target.min) && value < Number(e.target.min)) {
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
value = Number(e.target.min)
|
value = Number(e.target.min)
|
||||||
|
e.target.value = value
|
||||||
}
|
}
|
||||||
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
value = Number(e.target.dataset.min)
|
value = Number(e.target.dataset.min)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@ import EventBinding from '../../Element/Dialog/eventBinding';
|
|||||||
import richText from "../../Element/richText";
|
import richText from "../../Element/richText";
|
||||||
import MouseEvent from '../../../Event/index'
|
import MouseEvent from '../../../Event/index'
|
||||||
import LabelObject from '../LabelObject'
|
import LabelObject from '../LabelObject'
|
||||||
import { syncData } from '../../../Global/MultiViewportMode'
|
import { syncData, getSdk as get2DSdk } from '../../../Global/MultiViewportMode'
|
||||||
import { legp } from '../../Element/datalist';
|
import { legp } from '../../Element/datalist';
|
||||||
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
|
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
|
||||||
import MouseTip from '../../../MouseTip'
|
import MouseTip from '../../../MouseTip'
|
||||||
@ -20,14 +20,44 @@ class RadarScan extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 圆属性
|
* @param options {object} 圆属性
|
||||||
* @param options.id {string} 标注id
|
* @param options.id {string} 标注id
|
||||||
* @param [options.show=true] {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.lng {number} 经度
|
* @param options.lng {number} 经度
|
||||||
* @param options.lat {number} 维度
|
* @param options.lat {number} 维度
|
||||||
* @param options.color=#1FA8E3 {string} 颜色
|
* @param options.color=#FFEB3B {string} 颜色
|
||||||
* @param options.radius=10 {number} 半径
|
* @param options.radius=10 {number} 半径
|
||||||
* @param options.speed=20 {number} 速度
|
* @param options.speed=20 {number} 速度
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.label {object} 标签对象
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param {object} options.attribute.link={} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
*/
|
*/
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
@ -53,8 +83,8 @@ class RadarScan extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -138,7 +168,7 @@ class RadarScan extends Base {
|
|||||||
})
|
})
|
||||||
that.sdk._entityZIndex++
|
that.sdk._entityZIndex++
|
||||||
if (that.sdk.viewer._element.className === 'cesium-viewer 2d') {
|
if (that.sdk.viewer._element.className === 'cesium-viewer 2d') {
|
||||||
that.entity.ellipse.height = 1000000
|
that.entity.ellipse.height = 1
|
||||||
}
|
}
|
||||||
RadarScan.createLabel(that)
|
RadarScan.createLabel(that)
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
@ -246,16 +276,29 @@ class RadarScan extends Base {
|
|||||||
|
|
||||||
set show(v) {
|
set show(v) {
|
||||||
if (typeof v === "boolean") {
|
if (typeof v === "boolean") {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
|
if (!this.isShowView || !sdkD) {
|
||||||
this.options.show = v
|
this.options.show = v
|
||||||
this.entity.show = v
|
}
|
||||||
|
if (!this.showView || this.showView == 3 || !sdkD) {
|
||||||
|
this.entity.show = this.options.show
|
||||||
|
if (this.options.label.show && this.label) {
|
||||||
|
this.label.show = this.options.show
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.entity.show = false
|
||||||
|
if (this.options.label.show && this.label) {
|
||||||
|
this.label.show = false
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this._DialogObject && this._DialogObject.showBtn) {
|
if (this._DialogObject && this._DialogObject.showBtn) {
|
||||||
this._DialogObject.showBtn.checked = v
|
this._DialogObject.showBtn.checked = v
|
||||||
}
|
}
|
||||||
if (this.options.label.show && this.label) {
|
|
||||||
this.label.show = v
|
|
||||||
}
|
|
||||||
syncData(this.sdk, this.options.id)
|
syncData(this.sdk, this.options.id)
|
||||||
syncSplitData(this.sdk, this.options.id)
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
this.isShowView = false
|
||||||
} else {
|
} else {
|
||||||
console.error("参数必须为boolean")
|
console.error("参数必须为boolean")
|
||||||
}
|
}
|
||||||
@ -425,7 +468,7 @@ class RadarScan extends Base {
|
|||||||
this.changeMaterial()
|
this.changeMaterial()
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -448,8 +491,9 @@ class RadarScan extends Base {
|
|||||||
return this.options.label.show
|
return this.options.label.show
|
||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
|
let sdkD = get2DSdk().sdkD
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && (!this.showView || this.showView == 3 || !sdkD)) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -483,7 +527,7 @@ class RadarScan extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -583,7 +627,7 @@ class RadarScan extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -594,7 +638,7 @@ class RadarScan extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -610,7 +654,7 @@ class RadarScan extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -636,7 +680,7 @@ class RadarScan extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1021,9 +1065,9 @@ class RadarScan extends Base {
|
|||||||
else if (this.options.positions) {
|
else if (this.options.positions) {
|
||||||
position = { ...this.options.positions[0] }
|
position = { ...this.options.positions[0] }
|
||||||
}
|
}
|
||||||
else if (this.options.center) {
|
// else if (this.options.center) {
|
||||||
position = { ...this.options.center }
|
// position = { ...this.options.center }
|
||||||
}
|
// }
|
||||||
else if (this.options.start) {
|
else if (this.options.start) {
|
||||||
position = { ...this.options.start }
|
position = { ...this.options.start }
|
||||||
}
|
}
|
||||||
@ -1124,7 +1168,7 @@ class RadarScan extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('radar-scan-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('radar-scan-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1138,7 +1182,7 @@ class RadarScan extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1152,7 +1196,7 @@ class RadarScan extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1166,7 +1210,7 @@ class RadarScan extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1180,7 +1224,7 @@ class RadarScan extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1374,7 +1418,7 @@ class RadarScan extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async remove() {
|
async remove() {
|
||||||
this.label.remove()
|
this.label && this.label.remove()
|
||||||
this.entity && this.sdk.viewer.entities.remove(this.entity)
|
this.entity && this.sdk.viewer.entities.remove(this.entity)
|
||||||
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
|
this.entity2 && this.sdk.viewer.entities.remove(this.entity2)
|
||||||
this.entity = null
|
this.entity = null
|
||||||
|
|||||||
@ -23,16 +23,46 @@ class RadarScanStereoscopic extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
* @param options.id {string} 标注id
|
* @param options.id {string} 标注id
|
||||||
* @param [options.show=true] {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.lng {number} 经度
|
* @param options.lng {number} 经度
|
||||||
* @param options.lat {number} 纬度
|
* @param options.lat {number} 纬度
|
||||||
* @param options.alt {number} 高度
|
* @param options.alt {number} 高度
|
||||||
* @param options.colorOut=#ff0000 {string} 范围颜色
|
* @param options.colorOut=rgba(255,255,0,0.3){string} 范围颜色
|
||||||
* @param options.colorIn=#ff0000 {string} 扫描颜色
|
* @param options.colorIn=rgba(255,0,0,0.3){string} 扫描颜色
|
||||||
* @param options.radius=10 {number} 半径
|
* @param options.radius=10 {number} 半径
|
||||||
* @param options.duration=2000 {number} 持续时间
|
* @param options.duration=2000 {number} 持续时间
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.label {object} 标签对象
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param {object} options.attribute.link={} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
*/
|
*/
|
||||||
constructor(sdk, options, _Dialog = {}) {
|
constructor(sdk, options, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
@ -58,8 +88,8 @@ class RadarScanStereoscopic extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -86,6 +116,10 @@ class RadarScanStereoscopic extends Base {
|
|||||||
RadarScanStereoscopic.radarSolidScan(this)
|
RadarScanStereoscopic.radarSolidScan(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get type() {
|
||||||
|
return 'RadarScanStereoscopic'
|
||||||
|
}
|
||||||
|
|
||||||
static radarSolidScan(that) {
|
static radarSolidScan(that) {
|
||||||
let viewer = that.sdk.viewer
|
let viewer = that.sdk.viewer
|
||||||
let options = that.options
|
let options = that.options
|
||||||
@ -369,7 +403,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.entity.ellipsoid.outlineColor = Cesium.Color.fromCssColorString(v)
|
this.entity.ellipsoid.outlineColor = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.colorOut) {
|
if (this._elms.colorOut) {
|
||||||
this._elms.colorOut.forEach((item, i) => {
|
this._elms.colorOut.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -396,7 +430,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.entity.wall.material = Cesium.Color.fromCssColorString(v)
|
this.entity.wall.material = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.colorIn) {
|
if (this._elms.colorIn) {
|
||||||
this._elms.colorIn.forEach((item, i) => {
|
this._elms.colorIn.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -420,7 +454,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -454,7 +488,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -554,7 +588,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -565,7 +599,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -581,7 +615,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -607,7 +641,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1026,7 +1060,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('radar-scan-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('radar-scan-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorOutPicker = new ewPlugins('colorpicker', {
|
let colorOutPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("colorOut")[0],
|
el: contentElm.getElementsByClassName("colorOut")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1040,7 +1074,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.colorOut = 'rgba(255,255,255,1)'
|
this.colorOut = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let colorInPicker = new ewPlugins('colorpicker', {
|
let colorInPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("colorIn")[0],
|
el: contentElm.getElementsByClassName("colorIn")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1054,7 +1088,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.colorIn = 'rgba(255,255,255,1)'
|
this.colorIn = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1068,7 +1102,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1082,7 +1116,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1096,7 +1130,7 @@ class RadarScanStereoscopic extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1283,9 +1317,9 @@ class RadarScanStereoscopic extends Base {
|
|||||||
else if (this.options.positions) {
|
else if (this.options.positions) {
|
||||||
position = { ...this.options.positions[0] }
|
position = { ...this.options.positions[0] }
|
||||||
}
|
}
|
||||||
else if (this.options.center) {
|
// else if (this.options.center) {
|
||||||
position = { ...this.options.center }
|
// position = { ...this.options.center }
|
||||||
}
|
// }
|
||||||
else if (this.options.start) {
|
else if (this.options.start) {
|
||||||
position = { ...this.options.start }
|
position = { ...this.options.start }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class Corridor extends Base {
|
|||||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
}
|
}
|
||||||
|
|
||||||
let length = this.computeDistance(positions)
|
let length = this.computeDistance2(positions)
|
||||||
|
|
||||||
let geometry = new Cesium.CorridorGeometry({
|
let geometry = new Cesium.CorridorGeometry({
|
||||||
positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class Corridor extends Base {
|
|||||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||||
}
|
}
|
||||||
|
|
||||||
let length = this.computeDistance(positions)
|
let length = this.computeDistance2(positions)
|
||||||
|
|
||||||
let geometry = new Cesium.CorridorGeometry({
|
let geometry = new Cesium.CorridorGeometry({
|
||||||
positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
||||||
|
|||||||
39
src/Obj/Base/RoadObject/_element.js
Normal file
39
src/Obj/Base/RoadObject/_element.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
function html() {
|
||||||
|
return `
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">名称</span>
|
||||||
|
<input class="input" maxlength="40" type="text" @model="name">
|
||||||
|
</div>
|
||||||
|
<div class="col road-box">
|
||||||
|
<span class="label" style="flex: 0 0 56px;">道路类型</span>
|
||||||
|
<div class="road-type"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
<div class="div-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">车道宽度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" max="99999" min="1" step="1" @model="carRoadWidth">
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<span class="label">人行道宽度</span>
|
||||||
|
<div class="input-number input-number-unit-1">
|
||||||
|
<input class="input" type="number" title="" max="99999" min="1" step="1" @model="sideWidth">
|
||||||
|
<span class="arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="custom-divider"></span>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export { html }
|
||||||
92
src/Obj/Base/RoadObject/eventBinding.js
Normal file
92
src/Obj/Base/RoadObject/eventBinding.js
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
class eventBinding {
|
||||||
|
constructor() {
|
||||||
|
this.element = {}
|
||||||
|
}
|
||||||
|
static event = {}
|
||||||
|
|
||||||
|
getEvent(name) {
|
||||||
|
return eventBinding.event[name]
|
||||||
|
}
|
||||||
|
|
||||||
|
getEventAll() {
|
||||||
|
return eventBinding.event
|
||||||
|
}
|
||||||
|
|
||||||
|
setEvent(name, event) {
|
||||||
|
eventBinding.event[name] = event
|
||||||
|
}
|
||||||
|
|
||||||
|
on(that, elements) {
|
||||||
|
for (let i = 0; i < elements.length; i++) {
|
||||||
|
let Event = []
|
||||||
|
let isEvent = false
|
||||||
|
let removeName = []
|
||||||
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (let m of elements[i].attributes) {
|
||||||
|
switch (m.name) {
|
||||||
|
case '@model': {
|
||||||
|
isEvent = true
|
||||||
|
if (elements[i].type == 'checkbox') {
|
||||||
|
Event.push((e) => { that[m.value] = e.target.checked })
|
||||||
|
elements[i].checked = that[m.value]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Event.push((e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.type == 'number') {
|
||||||
|
value = Number(value)
|
||||||
|
}
|
||||||
|
that[m.value] = value
|
||||||
|
})
|
||||||
|
if (elements[i].nodeName == 'IMG') {
|
||||||
|
elements[i].src = that[m.value]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elements[i].value = that[m.value]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.element[m.value]) {
|
||||||
|
this.element[m.value].push(elements[i])
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.element[m.value] = [elements[i]]
|
||||||
|
}
|
||||||
|
removeName.push(m.name)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '@click': {
|
||||||
|
elements[i].addEventListener('click', (e) => {
|
||||||
|
if (typeof (that.Dialog[m.value]) === 'function') {
|
||||||
|
that.Dialog[m.value](e)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
removeName.push(m.name)
|
||||||
|
// elements[i].attributes.removeNamedItem(m.name)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// elements[i].attributes[m] = undefined
|
||||||
|
}
|
||||||
|
for (let n = 0; n < removeName.length; n++) {
|
||||||
|
elements[i].attributes.removeNamedItem(removeName[n])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEvent) {
|
||||||
|
let ventType = 'input'
|
||||||
|
if (elements[i].tagName != 'INPUT' || elements[i].type == 'checkbox') {
|
||||||
|
ventType = 'change'
|
||||||
|
}
|
||||||
|
elements[i].addEventListener(ventType, (e) => {
|
||||||
|
for (let t = 0; t < Event.length; t++) {
|
||||||
|
Event[t](e)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const EventBinding = new eventBinding();
|
||||||
|
export default EventBinding;
|
||||||
1549
src/Obj/Base/RoadObject/index-8.4.js
Normal file
1549
src/Obj/Base/RoadObject/index-8.4.js
Normal file
File diff suppressed because it is too large
Load Diff
1704
src/Obj/Base/RoadObject/index-last.js
Normal file
1704
src/Obj/Base/RoadObject/index-last.js
Normal file
File diff suppressed because it is too large
Load Diff
889
src/Obj/Base/RoadObject/index-拐角连接.js
Normal file
889
src/Obj/Base/RoadObject/index-拐角连接.js
Normal file
@ -0,0 +1,889 @@
|
|||||||
|
/**
|
||||||
|
* @description 道路
|
||||||
|
*/
|
||||||
|
import Dialog from '../../Element/Dialog';
|
||||||
|
import { html } from "./_element";
|
||||||
|
import EventBinding from '../../Element/Dialog/eventBinding';
|
||||||
|
import Base from "../index";
|
||||||
|
import { syncData } from '../../../Global/MultiViewportMode'
|
||||||
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
||||||
|
|
||||||
|
class Road extends Base {
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
|
* @description 道路
|
||||||
|
* @param options {object} 道路属性
|
||||||
|
* @param options.name=未命名对象 {string} 名称
|
||||||
|
* @param options.carRoadWidth=2 {number} 车道宽度
|
||||||
|
* @param options.sideWidth=2 {number} 人行道宽度
|
||||||
|
* @param options.positions=[] {array} 道路positions
|
||||||
|
* @param options.roadImage='' {string} 车道贴图
|
||||||
|
* @param options.sideImage='' {string} 人行道贴图
|
||||||
|
* @param Dialog {object} 弹框对象
|
||||||
|
* @param Dialog.confirmCallBack {function} 弹框确认时的回调
|
||||||
|
* */
|
||||||
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
|
super(sdk, options);
|
||||||
|
this.viewer = this.sdk.viewer
|
||||||
|
this.options.name = options.name || '道路'
|
||||||
|
this.options.carRoadWidth = options.carRoadWidth || 10
|
||||||
|
this.options.sideWidth = options.sideWidth || 5
|
||||||
|
this.options.positions = options.positions || []
|
||||||
|
this.options.roadImage = options.roadImage || (this.getSourceRootPath() + '/img/roadPhoto.png')
|
||||||
|
this.options.sideImage = options.sideImage || (this.getSourceRootPath() + '/img/sidePhoto.png')
|
||||||
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
|
this.Dialog = _Dialog
|
||||||
|
this._EventBinding = new EventBinding()
|
||||||
|
this._elms = {};
|
||||||
|
this.positionArea = []
|
||||||
|
this.positions = []
|
||||||
|
this.lineEntity = ''
|
||||||
|
|
||||||
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
|
Road.create(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建道路
|
||||||
|
static create(that) {
|
||||||
|
let positions = []
|
||||||
|
that.options.positions.forEach(v => {
|
||||||
|
positions.push(new Cesium.Cartesian3.fromDegrees(v.lng, v.lat, v.alt))
|
||||||
|
})
|
||||||
|
|
||||||
|
let area = [[], [], []]
|
||||||
|
area[1] = that.createLineBufferPolygon2(positions, that.options.carRoadWidth / 2)
|
||||||
|
area[0] = that.createLineBufferPolygonSide(area[1][2], -that.options.sideWidth)
|
||||||
|
area[2] = that.createLineBufferPolygonSide(area[1][1], that.options.sideWidth)
|
||||||
|
|
||||||
|
//判断道路边是否相交
|
||||||
|
for (let i = 0; i < area[0].length - 1; i++) {
|
||||||
|
|
||||||
|
let leftItem = area[0][i]
|
||||||
|
let leftItem2 = area[0][i + 1]
|
||||||
|
let rightItem = area[2][i]
|
||||||
|
let rightItem2 = area[2][i + 1]
|
||||||
|
let carItem = area[1][0][i]
|
||||||
|
let carItem2 = area[1][0][i + 1]
|
||||||
|
let leftLine = that.getIntersects(leftItem[1], leftItem[2], leftItem2[1], leftItem2[2])
|
||||||
|
let rightLine = that.getIntersects(rightItem[1], rightItem[2], rightItem2[1], rightItem2[2])
|
||||||
|
|
||||||
|
console.log(leftLine, 'leftLine')
|
||||||
|
if (leftLine) {//左侧相交
|
||||||
|
//获取右侧延长交点
|
||||||
|
let point1 = that.getExtendPoint(rightItem[1], rightItem[2], 1000)
|
||||||
|
let point2 = that.getExtendPoint(rightItem2[2], rightItem2[1], 1000)
|
||||||
|
let rightIntersection = that.getIntersects(rightItem[2], point1, rightItem2[1], point2)
|
||||||
|
//将其他几条边都延长
|
||||||
|
let leftLineNeiPoint = that.getExtendPoint(leftItem[0], leftItem[3], 1000)
|
||||||
|
let carLeftPoint = that.getExtendPoint(carItem[3], carItem[2], 1000)
|
||||||
|
let carRightPoint = that.getExtendPoint(carItem[0], carItem[1], 1000)
|
||||||
|
let rightLineNeiPoint = that.getExtendPoint(rightItem[0], rightItem[3], 1000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//跟左侧里相交点
|
||||||
|
let leftLineNei = that.getIntersects(leftLine, rightIntersection, leftItem[0], leftLineNeiPoint)
|
||||||
|
//跟车道左侧相交点
|
||||||
|
let carLeft = that.getIntersects(leftLine, rightIntersection, carItem[3], carLeftPoint)
|
||||||
|
//跟车道右侧相交点
|
||||||
|
let carRight = that.getIntersects(leftLine, rightIntersection, carItem[0], carRightPoint)
|
||||||
|
let rightLineNei = that.getIntersects(leftLine, rightIntersection, rightItem[0], rightLineNeiPoint)
|
||||||
|
|
||||||
|
// let leftLineNei = that.getIntersects(leftLine, rightItem[2], leftItem[0], leftItem[3])
|
||||||
|
// let carLeft = that.getIntersects(leftLine, rightItem[2], carItem[3], carItem[2])
|
||||||
|
// let carRight = that.getIntersects(leftLine, rightItem[2], carItem[0], carItem[1])
|
||||||
|
// let rightLineNei = that.getIntersects(leftLine, rightItem[2], rightItem[0], rightItem[3])
|
||||||
|
|
||||||
|
// let leftLineNei = that.getIntersects(leftLine, intersection, leftItem[0], leftItem[3])
|
||||||
|
// //跟车道左侧相交点
|
||||||
|
// let carLeft = that.getIntersects(leftLine, intersection, carItem[3], carItem[2])
|
||||||
|
// //跟车道右侧相交点
|
||||||
|
// let carRight = that.getIntersects(leftLine, intersection, carItem[0], carItem[1])
|
||||||
|
// let rightLineNei = that.getIntersects(leftLine, intersection, rightItem[0], rightItem[3])
|
||||||
|
|
||||||
|
leftItem[2] = leftLine
|
||||||
|
leftItem[3] = leftLineNei
|
||||||
|
carItem[2] = carLeft
|
||||||
|
carItem[1] = carRight
|
||||||
|
rightItem[3] = rightLineNei
|
||||||
|
rightItem[2] = rightIntersection
|
||||||
|
console.log(leftItem, carItem, rightItem, 'leftItemleft')
|
||||||
|
|
||||||
|
|
||||||
|
//将其他几条边都延长
|
||||||
|
let leftLineNeiPoint2 = that.getExtendPoint(leftItem2[3], leftItem2[0], 1000)
|
||||||
|
let carLeftPoint2 = that.getExtendPoint(carItem2[2], carItem2[3], 1000)
|
||||||
|
let carRightPoint2 = that.getExtendPoint(carItem2[1], carItem2[0], 1000)
|
||||||
|
let rightLineNeiPoint2 = that.getExtendPoint(rightItem2[3], rightItem2[0], 1000)
|
||||||
|
|
||||||
|
// let leftLineNei2 = that.getIntersects(leftLine, rightItem2[1], leftItem2[0], leftItem2[3])
|
||||||
|
// let carLeft2 = that.getIntersects(leftLine, rightItem2[1], carItem2[3], carItem2[2])
|
||||||
|
// let carRight2 = that.getIntersects(leftLine, rightItem2[1], carItem2[0], carItem2[1])
|
||||||
|
// let rightLineNei2 = that.getIntersects(leftLine, rightItem2[1], rightItem2[0], rightItem2[3])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let leftLineNei2 = that.getIntersects(leftLine, rightIntersection, leftItem2[3], leftLineNeiPoint2)
|
||||||
|
let carLeft2 = that.getIntersects(leftLine, rightIntersection, carItem2[2], carLeftPoint2)
|
||||||
|
let carRight2 = that.getIntersects(leftLine, rightIntersection, carItem2[1], carRightPoint2)
|
||||||
|
let rightLineNei2 = that.getIntersects(leftLine, rightIntersection, rightItem2[3], rightLineNeiPoint2)
|
||||||
|
|
||||||
|
// let arr = [leftLine, rightIntersection, leftItem2[3], leftLineNeiPoint2]
|
||||||
|
// arr.forEach((item, index) => {
|
||||||
|
// that.sdk.viewer.entities.add({
|
||||||
|
// name: 'node-secondary-edit-point',
|
||||||
|
// index: i,
|
||||||
|
// position: item,
|
||||||
|
// billboard: {
|
||||||
|
// image: that.getSourceRootPath() + '/img/point.png',
|
||||||
|
// width: 15,
|
||||||
|
// height: 15,
|
||||||
|
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
|
// color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||||
|
// },
|
||||||
|
// label: {
|
||||||
|
// text: '' + index,
|
||||||
|
// pixelOffset: { x: 0, y: -20 },
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
|
// let leftLineNei2 = that.getIntersects(leftLine, intersection, leftItem2[0], leftItem2[3])
|
||||||
|
// //跟车道左侧相交点
|
||||||
|
// let carLeft2 = that.getIntersects(leftLine, intersection, carItem2[3], carItem2[2])
|
||||||
|
// //跟车道右侧相交点
|
||||||
|
// let carRight2 = that.getIntersects(leftLine, intersection, carItem2[0], carItem2[1])
|
||||||
|
// let rightLineNei2 = that.getIntersects(leftLine, intersection, rightItem2[0], rightItem2[3])
|
||||||
|
|
||||||
|
leftItem2[1] = leftLine
|
||||||
|
leftItem2[0] = leftLineNei2
|
||||||
|
carItem2[3] = carLeft2
|
||||||
|
carItem2[0] = carRight2
|
||||||
|
rightItem2[0] = rightLineNei2
|
||||||
|
rightItem2[1] = rightIntersection
|
||||||
|
console.log(leftItem2, carItem2, rightItem2, 'leftItem2left')
|
||||||
|
|
||||||
|
} else if (rightLine) {//右侧相交
|
||||||
|
|
||||||
|
//获取左侧延长交点
|
||||||
|
let point1 = that.getExtendPoint(leftItem[1], leftItem[2], 1000)
|
||||||
|
let point2 = that.getExtendPoint(leftItem2[2], leftItem2[1], 1000)
|
||||||
|
let rightIntersection = that.getIntersects(leftItem[2], point1, leftItem2[1], point2)
|
||||||
|
//将其他几条边都延长
|
||||||
|
let leftLineNeiPoint = that.getExtendPoint(leftItem[0], leftItem[3], 1000)
|
||||||
|
let carLeftPoint = that.getExtendPoint(carItem[3], carItem[2], 1000)
|
||||||
|
let carRightPoint = that.getExtendPoint(carItem[0], carItem[1], 1000)
|
||||||
|
let rightLineNeiPoint = that.getExtendPoint(rightItem[0], rightItem[3], 1000)
|
||||||
|
|
||||||
|
// //跟左侧里相交点
|
||||||
|
let leftLineNei = that.getIntersects(rightLine, rightIntersection, leftItem[0], leftLineNeiPoint)
|
||||||
|
//跟车道左侧相交点
|
||||||
|
let carLeft = that.getIntersects(rightLine, rightIntersection, carItem[3], carLeftPoint)
|
||||||
|
//跟车道右侧相交点
|
||||||
|
let carRight = that.getIntersects(rightLine, rightIntersection, carItem[0], carRightPoint)
|
||||||
|
let rightLineNei = that.getIntersects(rightLine, rightIntersection, rightItem[0], rightLineNeiPoint)
|
||||||
|
// //跟左侧里相交点
|
||||||
|
// let leftLineNei = that.getIntersects(rightLine, leftItem[2], leftItem[0], leftItem[3])
|
||||||
|
// //跟车道左侧相交点
|
||||||
|
// let carLeft = that.getIntersects(rightLine, leftItem[2], carItem[3], carItem[2])
|
||||||
|
// //跟车道右侧相交点
|
||||||
|
// let carRight = that.getIntersects(rightLine, leftItem[2], carItem[0], carItem[1])
|
||||||
|
// let rightLineNei = that.getIntersects(rightLine, leftItem[2], rightItem[0], rightItem[3])
|
||||||
|
|
||||||
|
|
||||||
|
leftItem[2] = rightIntersection
|
||||||
|
leftItem[3] = leftLineNei
|
||||||
|
carItem[2] = carLeft
|
||||||
|
carItem[1] = carRight
|
||||||
|
rightItem[3] = rightLineNei
|
||||||
|
rightItem[2] = rightLine
|
||||||
|
console.log(leftItem, carItem, rightItem, 'leftItemright')
|
||||||
|
|
||||||
|
//将其他几条边都延长
|
||||||
|
let leftLineNeiPoint2 = that.getExtendPoint(leftItem2[3], leftItem2[0], 1000)
|
||||||
|
let carLeftPoint2 = that.getExtendPoint(carItem2[2], carItem2[3], 1000)
|
||||||
|
let carRightPoint2 = that.getExtendPoint(carItem2[1], carItem2[0], 1000)
|
||||||
|
let rightLineNeiPoint2 = that.getExtendPoint(rightItem2[3], rightItem2[0], 1000)
|
||||||
|
|
||||||
|
let leftLineNei2 = that.getIntersects(rightLine, rightIntersection, leftItem2[3], leftLineNeiPoint2)
|
||||||
|
//跟车道左侧相交点
|
||||||
|
let carLeft2 = that.getIntersects(rightLine, rightIntersection, carItem2[2], carLeftPoint2)
|
||||||
|
//跟车道右侧相交点
|
||||||
|
let carRight2 = that.getIntersects(rightLine, rightIntersection, carItem2[1], carRightPoint2)
|
||||||
|
let rightLineNei2 = that.getIntersects(rightLine, rightIntersection, rightItem2[3], rightLineNeiPoint2)
|
||||||
|
// let leftLineNei2 = that.getIntersects(rightLine, leftItem2[1], leftItem2[0], leftItem2[3])
|
||||||
|
// //跟车道左侧相交点
|
||||||
|
// let carLeft2 = that.getIntersects(rightLine, leftItem2[1], carItem2[3], carItem2[2])
|
||||||
|
// //跟车道右侧相交点
|
||||||
|
// let carRight2 = that.getIntersects(rightLine, leftItem2[1], carItem2[0], carItem2[1])
|
||||||
|
// let rightLineNei2 = that.getIntersects(rightLine, leftItem2[1], rightItem2[0], rightItem2[3])
|
||||||
|
|
||||||
|
leftItem2[1] = rightIntersection
|
||||||
|
leftItem2[0] = leftLineNei2
|
||||||
|
carItem2[3] = carLeft2
|
||||||
|
carItem2[0] = carRight2
|
||||||
|
rightItem2[0] = rightLineNei2
|
||||||
|
rightItem2[1] = rightLine
|
||||||
|
console.log(leftItem2, carItem2, rightItem2, 'leftItem2right')
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(area[0], 'area')
|
||||||
|
|
||||||
|
if (that.viewer.entities.getById(that.options.id)) {
|
||||||
|
that.viewer.entities.getById(that.options.id)._children.forEach((item) => {
|
||||||
|
that.viewer.entities.remove(item);
|
||||||
|
});
|
||||||
|
that.viewer.entities.remove(that.viewer.entities.getById(that.options.id))
|
||||||
|
}
|
||||||
|
that.lineEntity = that.viewer.entities.add(new Cesium.Entity({ id: that.options.id, show: that.options.show }))
|
||||||
|
|
||||||
|
const myImg = new Image()
|
||||||
|
myImg.src = that.options.roadImage
|
||||||
|
myImg.onload = function () {
|
||||||
|
console.log(area[1][0], 'arr')
|
||||||
|
area[1][0].forEach((item, index) => {
|
||||||
|
that.viewer.entities.add({
|
||||||
|
// id: that.options.id,
|
||||||
|
parent: that.lineEntity,
|
||||||
|
polygon: {
|
||||||
|
hierarchy: new Cesium.PolygonHierarchy(item),
|
||||||
|
material: new Cesium.ImageMaterialProperty({
|
||||||
|
image: that.options.roadImage,
|
||||||
|
transparent: true,// 如果图片有透明部分,需要设置为 true
|
||||||
|
repeat: that.calculateTextureRepeat(item, myImg)
|
||||||
|
}),
|
||||||
|
stRotation: that.calculateRoadAngle(positions[index], positions[index + 1])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const myImg2 = new Image()
|
||||||
|
myImg2.src = that.options.sideImage
|
||||||
|
myImg2.onload = function () {
|
||||||
|
area[0].forEach((item, index) => {
|
||||||
|
that.viewer.entities.add({
|
||||||
|
parent: that.lineEntity,
|
||||||
|
polygon: {
|
||||||
|
hierarchy: new Cesium.PolygonHierarchy(item),
|
||||||
|
material: new Cesium.ImageMaterialProperty({
|
||||||
|
image: that.options.sideImage,
|
||||||
|
transparent: true,// 如果图片有透明部分,需要设置为 true
|
||||||
|
repeat: that.calculateTextureRepeat(item, myImg2)
|
||||||
|
}),
|
||||||
|
stRotation: that.calculateRoadAngle(positions[index], positions[index + 1])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
area[2].forEach((item, index) => {
|
||||||
|
that.viewer.entities.add({
|
||||||
|
polygon: {
|
||||||
|
hierarchy: new Cesium.PolygonHierarchy(item),
|
||||||
|
material: new Cesium.ImageMaterialProperty({
|
||||||
|
image: that.options.sideImage,
|
||||||
|
transparent: true,// 如果图片有透明部分,需要设置为 true
|
||||||
|
repeat: that.calculateTextureRepeat(item, myImg2)
|
||||||
|
}),
|
||||||
|
stRotation: that.calculateRoadAngle(positions[index], positions[index + 1])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
getExtendPoint(position1, position2, distance) {
|
||||||
|
// let position1 = Cesium.Cartesian3.fromDegrees(p1[0], p1[1], 0);
|
||||||
|
// let position2 = Cesium.Cartesian3.fromDegrees(p2[0], p2[1], 0);
|
||||||
|
let pot = Cesium.Cartesian3.subtract(position2, position1, new Cesium.Cartesian3());//方向
|
||||||
|
var dir = Cesium.Cartesian3.normalize(pot, new Cesium.Cartesian3());//向量归一化
|
||||||
|
|
||||||
|
var ray = new Cesium.Ray(position1, dir);
|
||||||
|
let np = Cesium.Ray.getPoint(ray, distance * 10);//计算延长点
|
||||||
|
return np
|
||||||
|
}
|
||||||
|
getArr(arr1, arr2) {
|
||||||
|
arr2 = arr2.reverse()
|
||||||
|
let polygon = []
|
||||||
|
for (let index = 0; index < arr1.length - 1; index++) {
|
||||||
|
polygon.push([arr1[index], arr1[index + 1], arr2[index + 1], arr2[index]])
|
||||||
|
}
|
||||||
|
return polygon
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateRoadAngle(startPoint, endPoint) {
|
||||||
|
// 1. 获取地表法向量
|
||||||
|
const normal = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(startPoint);
|
||||||
|
|
||||||
|
// 2. 构建精确ENU坐标系
|
||||||
|
const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(startPoint, undefined, normal);
|
||||||
|
const inverseMatrix = Cesium.Matrix4.inverse(enuMatrix, new Cesium.Matrix4());
|
||||||
|
|
||||||
|
// 3. 转换终点并计算水平向量
|
||||||
|
const localEnd = Cesium.Matrix4.multiplyByPoint(inverseMatrix, endPoint, new Cesium.Cartesian3());
|
||||||
|
const horizontalVec = new Cesium.Cartesian2(localEnd.x, localEnd.y);
|
||||||
|
Cesium.Cartesian2.normalize(horizontalVec, horizontalVec);
|
||||||
|
|
||||||
|
const north = new Cesium.Cartesian2(1, 0);
|
||||||
|
|
||||||
|
const angle = Cesium.Cartesian2.angleBetween(north, horizontalVec);
|
||||||
|
const cross = Cesium.Cartesian2.cross(north, horizontalVec, new Cesium.Cartesian2());
|
||||||
|
return cross < 0 ? angle : -angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
calculatePolygonOrientation(positions) {
|
||||||
|
|
||||||
|
// 假设 position 是 Cesium.Cartesian3 对象,表示地球上的某个点
|
||||||
|
var position = positions[0]
|
||||||
|
// 获取东、北、上坐标系
|
||||||
|
var eastNorthUp = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||||
|
// northAxis 是北方向向量
|
||||||
|
var northAxis = eastNorthUp.getColumn(1, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(northAxis, northAxis);
|
||||||
|
|
||||||
|
const direction = Cesium.Cartesian3.subtract(positions[0], positions[1], new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(direction, direction);
|
||||||
|
|
||||||
|
|
||||||
|
const dot = Cesium.Cartesian3.dot(northAxis, direction);
|
||||||
|
const magA = Cesium.Cartesian3.magnitude(northAxis);
|
||||||
|
const magB = Cesium.Cartesian3.magnitude(direction);
|
||||||
|
return Math.acos(dot / (magA * magB));
|
||||||
|
}
|
||||||
|
calculateTextureRepeat(polygonPositions, textureSize, meterPerPixel = 0.01) {
|
||||||
|
// 验证纹理尺寸
|
||||||
|
if (!textureSize.width || !textureSize.height) {
|
||||||
|
throw new Error('Texture size must contain width and height in pixels');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建多边形几何体
|
||||||
|
const geometry = Cesium.PolygonGeometry.createGeometry(
|
||||||
|
new Cesium.PolygonGeometry({
|
||||||
|
polygonHierarchy: new Cesium.PolygonHierarchy(polygonPositions),
|
||||||
|
vertexFormat: Cesium.VertexFormat.POSITION_ONLY
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// 计算多边形面积(平方米)
|
||||||
|
let area = 0;
|
||||||
|
const indices = geometry.indices;
|
||||||
|
const positions = geometry.attributes.position.values;
|
||||||
|
for (let i = 0; i < indices.length; i += 3) {
|
||||||
|
const i0 = indices[i] * 3;
|
||||||
|
const i1 = indices[i + 1] * 3;
|
||||||
|
const i2 = indices[i + 2] * 3;
|
||||||
|
|
||||||
|
const p0 = new Cesium.Cartesian3(positions[i0], positions[i0 + 1], positions[i0 + 2]);
|
||||||
|
const p1 = new Cesium.Cartesian3(positions[i1], positions[i1 + 1], positions[i1 + 2]);
|
||||||
|
const p2 = new Cesium.Cartesian3(positions[i2], positions[i2 + 1], positions[i2 + 2]);
|
||||||
|
|
||||||
|
const cross = Cesium.Cartesian3.cross(
|
||||||
|
Cesium.Cartesian3.subtract(p1, p0, new Cesium.Cartesian3()),
|
||||||
|
Cesium.Cartesian3.subtract(p2, p0, new Cesium.Cartesian3()),
|
||||||
|
new Cesium.Cartesian3()
|
||||||
|
);
|
||||||
|
area += Cesium.Cartesian3.magnitude(cross) * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将像素尺寸转换为实际尺寸(平方米)
|
||||||
|
const textureWidthMeters = textureSize.width * meterPerPixel;
|
||||||
|
const textureHeightMeters = textureSize.height * meterPerPixel;
|
||||||
|
const textureArea = textureWidthMeters * textureHeightMeters;
|
||||||
|
|
||||||
|
// 计算各轴向重复次数
|
||||||
|
const repeatX = Math.sqrt(area) / textureWidthMeters;
|
||||||
|
const repeatY = Math.sqrt(area) / textureHeightMeters;
|
||||||
|
|
||||||
|
return new Cesium.Cartesian2(Math.max(1, Math.ceil(repeatX)), 1.0);
|
||||||
|
}
|
||||||
|
swapLastElements(arr1, arr2) {
|
||||||
|
const last = arr1[arr1.length - 1]
|
||||||
|
const first = arr2[0]
|
||||||
|
arr1[arr1.length - 1] = first
|
||||||
|
arr2[0] = last
|
||||||
|
|
||||||
|
return [arr1, arr2];
|
||||||
|
}
|
||||||
|
createLineBufferPolygonSide(positions, width) {
|
||||||
|
let area = []
|
||||||
|
for (let i = 0; i < positions.length; i++) {
|
||||||
|
const posi = positions[i];
|
||||||
|
|
||||||
|
const dir = Cesium.Cartesian3.subtract(posi[1], posi[0], new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(dir, dir);
|
||||||
|
|
||||||
|
// 获取垂直向量(基于Z轴)
|
||||||
|
const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perp, perp);
|
||||||
|
|
||||||
|
// 生成偏移向量
|
||||||
|
const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3());
|
||||||
|
let point1 = Cesium.Cartesian3.add(posi[0], offset, new Cesium.Cartesian3())
|
||||||
|
let point3 = Cesium.Cartesian3.add(posi[1], offset, new Cesium.Cartesian3())
|
||||||
|
|
||||||
|
// i == positions.length - 2 ? area.push(start, point1, end, point3) : area.push(start, point1)
|
||||||
|
area.push([posi[0], point1, point3, posi[1]])
|
||||||
|
}
|
||||||
|
// let arr = []
|
||||||
|
// for (let i = 0; i < area.length - 2; i += 2) {
|
||||||
|
// arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]])
|
||||||
|
// }
|
||||||
|
return area
|
||||||
|
}
|
||||||
|
createLineBufferPolygon2(positions, width) {
|
||||||
|
let area = []
|
||||||
|
let leftPositions = [];
|
||||||
|
let rightPositions = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < positions.length - 1; i++) {
|
||||||
|
const start = positions[i];
|
||||||
|
// const end = positions[i + 1] || positions[i - 1];
|
||||||
|
const end = positions[i + 1];
|
||||||
|
|
||||||
|
const dir = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(dir, dir);
|
||||||
|
|
||||||
|
// 获取垂直向量(基于Z轴)
|
||||||
|
const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perp, perp);
|
||||||
|
|
||||||
|
const dir2 = Cesium.Cartesian3.subtract(start, end, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(dir2, dir2);
|
||||||
|
|
||||||
|
// 获取垂直向量(基于Z轴)
|
||||||
|
const perp2 = Cesium.Cartesian3.cross(dir2, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perp2, perp2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 生成偏移向量
|
||||||
|
const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3());
|
||||||
|
const offset2 = Cesium.Cartesian3.multiplyByScalar(perp, -width, new Cesium.Cartesian3());
|
||||||
|
|
||||||
|
const offsetEnd = Cesium.Cartesian3.multiplyByScalar(perp2, -width, new Cesium.Cartesian3());
|
||||||
|
const offsetEnd2 = Cesium.Cartesian3.multiplyByScalar(perp2, width, new Cesium.Cartesian3());
|
||||||
|
|
||||||
|
let point1 = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3())
|
||||||
|
let point2 = Cesium.Cartesian3.add(start, offset2, new Cesium.Cartesian3())
|
||||||
|
let point3 = Cesium.Cartesian3.add(end, offsetEnd, new Cesium.Cartesian3())
|
||||||
|
let point4 = Cesium.Cartesian3.add(end, offsetEnd2, new Cesium.Cartesian3())
|
||||||
|
|
||||||
|
area.push([point1, point3, point4, point2])
|
||||||
|
|
||||||
|
rightPositions.push([point1, point3])
|
||||||
|
leftPositions.push([point2, point4])
|
||||||
|
|
||||||
|
// if (i == positions.length - 2) {
|
||||||
|
// area.push(point1, point2, point3, point4)
|
||||||
|
// rightPositions.push(point1)
|
||||||
|
// leftPositions.push(point2)
|
||||||
|
// leftPositions.push(point4)
|
||||||
|
// rightPositions.push(point3)
|
||||||
|
// } else {
|
||||||
|
// area.push(point1, point2)
|
||||||
|
// rightPositions.push(point1)
|
||||||
|
// leftPositions.push(point2)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
// let arr = []
|
||||||
|
// for (let i = 0; i < area.length - 2; i += 2) {
|
||||||
|
// arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]])
|
||||||
|
// }
|
||||||
|
console.log(area, rightPositions, 'rightPositions')
|
||||||
|
let that = this
|
||||||
|
// return [arr, rightPositions, leftPositions]
|
||||||
|
return [area, rightPositions, leftPositions]
|
||||||
|
}
|
||||||
|
getIntersects(point1, point2, point3, point4) {
|
||||||
|
let carPoint1 = this.getLonLat(point1)
|
||||||
|
let carPoint2 = this.getLonLat(point2)
|
||||||
|
let carPoint3 = this.getLonLat(point3)
|
||||||
|
let carPoint4 = this.getLonLat(point4)
|
||||||
|
var line1 = turf.lineString([
|
||||||
|
[carPoint1.lon, carPoint1.lat],
|
||||||
|
[carPoint2.lon, carPoint2.lat]
|
||||||
|
]);
|
||||||
|
var line2 = turf.lineString([
|
||||||
|
[carPoint3.lon, carPoint3.lat],
|
||||||
|
[carPoint4.lon, carPoint4.lat]
|
||||||
|
]);
|
||||||
|
var intersects = turf.lineIntersect(line1, line2);
|
||||||
|
if (intersects.features.length > 0) {
|
||||||
|
console.log(intersects.features, 'ooooo')
|
||||||
|
return Cesium.Cartesian3.fromDegrees(intersects.features[0].geometry.coordinates[0], intersects.features[0].geometry.coordinates[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getLonLat(point) {
|
||||||
|
let pointDe = Cesium.Cartographic.fromCartesian(point)
|
||||||
|
const longitude = Cesium.Math.toDegrees(pointDe.longitude);
|
||||||
|
const latitude = Cesium.Math.toDegrees(pointDe.latitude);
|
||||||
|
return { lon: longitude, lat: latitude }
|
||||||
|
|
||||||
|
}
|
||||||
|
createLineBufferPolygon(viewer, positions, width) {
|
||||||
|
// 计算每个线段的左右偏移点
|
||||||
|
const leftPositions = [];
|
||||||
|
const rightPositions = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < positions.length; i++) {
|
||||||
|
const start = positions[i];
|
||||||
|
const end = positions[i + 1] || positions[i - 1];
|
||||||
|
|
||||||
|
// 计算线段方向向量
|
||||||
|
const direction = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
|
||||||
|
// const direction = Cesium.Cartesian3.subtract(start, end, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(direction, direction);
|
||||||
|
|
||||||
|
// 计算垂直向量(使用上向量叉积)
|
||||||
|
const up = Cesium.Cartesian3.UNIT_Z;
|
||||||
|
const perpendicular = Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perpendicular, perpendicular);
|
||||||
|
|
||||||
|
// 计算左右偏移点
|
||||||
|
const leftOffset = Cesium.Cartesian3.multiplyByScalar(
|
||||||
|
perpendicular,
|
||||||
|
width,
|
||||||
|
new Cesium.Cartesian3()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (width > 0) {
|
||||||
|
rightPositions.unshift(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3()));
|
||||||
|
} else if (width < 0) {
|
||||||
|
rightPositions.push(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return rightPositions
|
||||||
|
}
|
||||||
|
//计算角度
|
||||||
|
calculateAangle(arr) {
|
||||||
|
// let fromDegreesArray = that.calSector(that.options.center, that.options.radius, that.options.startAngle, that.options.endAngle, 360, true)
|
||||||
|
|
||||||
|
function getAangle(start, end) {
|
||||||
|
let rad = Math.PI / 180,
|
||||||
|
lat1 = start.y * rad,
|
||||||
|
lat2 = end.y * rad,
|
||||||
|
lon1 = start.x * rad,
|
||||||
|
lon2 = end.x * rad;
|
||||||
|
const a = Math.sin(lon2 - lon1) * Math.cos(lat2);
|
||||||
|
const b =
|
||||||
|
Math.cos(lat1) * Math.sin(lat2) -
|
||||||
|
Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
|
||||||
|
const radians = Math.atan2(a, b)
|
||||||
|
const degrees = radians % (2 * Math.PI);
|
||||||
|
let bearing = 450 - ((degrees * 180) / Math.PI < 0
|
||||||
|
? 360 + (degrees * 180) / Math.PI
|
||||||
|
: (degrees * 180) / Math.PI) - 90;
|
||||||
|
return 360 - (bearing % 360)
|
||||||
|
}
|
||||||
|
|
||||||
|
let center = arr[0]
|
||||||
|
let pos84_1 = arr[1]
|
||||||
|
let pos84_2 = arr[2]
|
||||||
|
|
||||||
|
let start = { x: center.lng, y: center.lat }
|
||||||
|
let end1 = { x: pos84_1.lng, y: pos84_1.lat }
|
||||||
|
let end2 = { x: pos84_2.lng, y: pos84_2.lat }
|
||||||
|
|
||||||
|
let angle1 = getAangle(start, end1)
|
||||||
|
let angle2 = getAangle(start, end2)
|
||||||
|
|
||||||
|
return {
|
||||||
|
angle1,
|
||||||
|
angle2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get carRoadWidth() {
|
||||||
|
return this.options.carRoadWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
set carRoadWidth(v) {
|
||||||
|
this.options.carRoadWidth = v
|
||||||
|
Road.create(this)
|
||||||
|
|
||||||
|
}
|
||||||
|
get sideWidth() {
|
||||||
|
return this.options.sideWidth
|
||||||
|
}
|
||||||
|
set sideWidth(v) {
|
||||||
|
this.options.sideWidth = v
|
||||||
|
Road.create(this)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description 编辑框
|
||||||
|
* @param state=false {boolean} 状态: true打开, false关闭
|
||||||
|
*/
|
||||||
|
async edit(state = false) {
|
||||||
|
let _this = this
|
||||||
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
|
||||||
|
if (this._DialogObject && this._DialogObject.close) {
|
||||||
|
this._DialogObject.close()
|
||||||
|
this._DialogObject = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
this._DialogObject = await new Dialog(this.sdk, this.originalOptions, {
|
||||||
|
title: '道路属性', left: '180px', top: '100px',
|
||||||
|
confirmCallBack: (options) => {
|
||||||
|
this.name = this.name.trim()
|
||||||
|
if (!this.name) {
|
||||||
|
this.name = '道路'
|
||||||
|
}
|
||||||
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
this._DialogObject.close()
|
||||||
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
},
|
||||||
|
resetCallBack: () => {
|
||||||
|
this.reset()
|
||||||
|
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
||||||
|
},
|
||||||
|
closeCallBack: () => {
|
||||||
|
this.reset()
|
||||||
|
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
|
||||||
|
},
|
||||||
|
showCallBack: (show) => {
|
||||||
|
this.show = show
|
||||||
|
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
||||||
|
}
|
||||||
|
}, true)
|
||||||
|
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' road-surface'
|
||||||
|
let contentElm = document.createElement('div');
|
||||||
|
contentElm.innerHTML = html()
|
||||||
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
|
|
||||||
|
|
||||||
|
// 下拉选项
|
||||||
|
// let heightModeData = [
|
||||||
|
// {
|
||||||
|
// name: '海拔高度',
|
||||||
|
// value: '海拔高度',
|
||||||
|
// key: '0',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: '相对地表',
|
||||||
|
// value: '相对地表',
|
||||||
|
// key: '1',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: '依附模型',
|
||||||
|
// value: '依附模型',
|
||||||
|
// key: '2',
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// let heightModeObject = legp(
|
||||||
|
// this._DialogObject._element.content.getElementsByClassName(
|
||||||
|
// 'road-box'
|
||||||
|
// )[0],
|
||||||
|
// '.road-type'
|
||||||
|
// )
|
||||||
|
// if (heightModeObject) {
|
||||||
|
// heightModeObject.legp_search(heightModeData)
|
||||||
|
// let heightModeDataLegpElm = this._DialogObject._element.content
|
||||||
|
// .getElementsByClassName('road-type')[0]
|
||||||
|
// .getElementsByTagName('input')[0]
|
||||||
|
// for (let i = 0; i < heightModeData.length; i++) {
|
||||||
|
// if (heightModeData[i].key == this.heightMode) {
|
||||||
|
// heightModeDataLegpElm.value = heightModeData[i].value
|
||||||
|
// heightModeObject.legp_searchActive(
|
||||||
|
// heightModeData[i].value
|
||||||
|
// )
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// heightModeDataLegpElm.addEventListener('input', () => {
|
||||||
|
// for (let i = 0; i < heightModeData.length; i++) {
|
||||||
|
// if (heightModeData[i].value === heightModeDataLegpElm.value) {
|
||||||
|
// this.heightMode = heightModeData[i].key
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
// this._elms.height = heightElm
|
||||||
|
// this._elms.heightBox = heightBoxElm
|
||||||
|
// this._elms.heightMode = heightModeDataLegpElm
|
||||||
|
// this._elms.heightConfirm = heightConfirmElm
|
||||||
|
// this._elms.heightModeObject = heightModeObject
|
||||||
|
|
||||||
|
// heightConfirmElm.addEventListener('click', () => {
|
||||||
|
// this.positionEditing = false
|
||||||
|
// for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
|
// this.options.positions[i].alt = Number((this.options.positions[i].alt + Number(heightElm.value)).toFixed(2))
|
||||||
|
// this._elms.alt[i].innerHTML = this.options.positions[i].alt
|
||||||
|
// }
|
||||||
|
// let fromDegreesArray = this.renewPositions(this.options.positions)
|
||||||
|
// this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
|
||||||
|
// fromDegreesArray
|
||||||
|
// )
|
||||||
|
|
||||||
|
// this.positionEditing = false
|
||||||
|
// PolylineObject.closeNodeEdit(this)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let all_elm = contentElm.getElementsByTagName("*")
|
||||||
|
this._EventBinding.on(this, all_elm)
|
||||||
|
this._elms = this._EventBinding.element
|
||||||
|
} else {
|
||||||
|
// if (this._element_style) {
|
||||||
|
// document.getElementsByTagName('head')[0].removeChild(this._element_style)
|
||||||
|
// this._element_style = null
|
||||||
|
// }
|
||||||
|
// if (this._DialogObject && this._DialogObject.remove) {
|
||||||
|
// this._DialogObject.remove()
|
||||||
|
// this._DialogObject = null
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
if (!this.viewer.entities.getById(this.options.id)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.name = this.originalOptions.name
|
||||||
|
this.carRoadWidth = this.originalOptions.carRoadWidth
|
||||||
|
this.sideWidth = this.originalOptions.sideWidth
|
||||||
|
this.positions = this.originalOptions.positions
|
||||||
|
this.roadImage = this.originalOptions.roadImage
|
||||||
|
this.sideImage = this.originalOptions.sideImage
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 飞到对应实体
|
||||||
|
*/
|
||||||
|
async flyTo(options = {}) {
|
||||||
|
setActiveViewer(0)
|
||||||
|
closeRotateAround(this.sdk)
|
||||||
|
closeViewFollow(this.sdk)
|
||||||
|
|
||||||
|
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
|
||||||
|
let orientation = {
|
||||||
|
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
|
||||||
|
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let lng = this.options.customView.relativePosition.lng
|
||||||
|
let lat = this.options.customView.relativePosition.lat
|
||||||
|
let alt = this.options.customView.relativePosition.alt
|
||||||
|
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
|
||||||
|
let position = { lng: 0, lat: 0 }
|
||||||
|
if (this.options.position) {
|
||||||
|
position = { ...this.options.position }
|
||||||
|
}
|
||||||
|
else if (this.options.positions) {
|
||||||
|
position = { ...this.options.positions[0] }
|
||||||
|
}
|
||||||
|
else if (this.options.center) {
|
||||||
|
position = { ...this.options.center }
|
||||||
|
}
|
||||||
|
else if (this.options.start) {
|
||||||
|
position = { ...this.options.start }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.options.hasOwnProperty('lng')) {
|
||||||
|
position.lng = this.options.lng
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('lat')) {
|
||||||
|
position.lat = this.options.lat
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('alt')) {
|
||||||
|
position.alt = this.options.alt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果没有高度值,则获取紧贴高度计算
|
||||||
|
// if (!position.hasOwnProperty('alt')) {
|
||||||
|
// position.alt = await this.getClampToHeight(position)
|
||||||
|
// }
|
||||||
|
lng = this.options.customView.relativePosition.lng + position.lng
|
||||||
|
lat = this.options.customView.relativePosition.lat + position.lat
|
||||||
|
alt = this.options.customView.relativePosition.alt + position.alt
|
||||||
|
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
this.sdk.viewer.camera.flyTo({
|
||||||
|
destination: destination,
|
||||||
|
orientation: orientation
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let positionArray = []
|
||||||
|
for (let i = 0; i < this.positions.length; i++) {
|
||||||
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
|
this.positions[i][0],
|
||||||
|
this.positions[i][1],
|
||||||
|
this.options.height + this.options.heightDifference / 2
|
||||||
|
)
|
||||||
|
positionArray.push(a.x, a.y, a.z)
|
||||||
|
}
|
||||||
|
let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray)
|
||||||
|
this.viewer.camera.flyToBoundingSphere(BoundingSphere, {
|
||||||
|
offset: {
|
||||||
|
heading: Cesium.Math.toRadians(0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(-20.0),
|
||||||
|
roll: Cesium.Math.toRadians(0.0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSphere() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
// entity没有加载完成时 state 不会等于0 所以设置定时器直到获取到为止
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const sphere = new Cesium.BoundingSphere()
|
||||||
|
const state = this.sdk.viewer._dataSourceDisplay.getBoundingSphere(
|
||||||
|
this.viewer.entities.getById(this.options.id),
|
||||||
|
false,
|
||||||
|
sphere
|
||||||
|
)
|
||||||
|
if (state === Cesium.BoundingSphereState.DONE) {
|
||||||
|
clearInterval(interval)
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
async remove() {
|
||||||
|
this.positions = []
|
||||||
|
this.lineEntity = null
|
||||||
|
|
||||||
|
if (this.viewer.entities.getById(this.options.id)) {
|
||||||
|
this.viewer.entities.getById(this.options.id)._children.forEach((item) => {
|
||||||
|
this.viewer.entities.remove(item);
|
||||||
|
});
|
||||||
|
this.viewer.entities.remove(this.viewer.entities.getById(this.options.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
||||||
|
this._DialogObject.close()
|
||||||
|
this._DialogObject = null
|
||||||
|
}
|
||||||
|
await this.sdk.removeIncetance(this.options.id)
|
||||||
|
await syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
flicker() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Road
|
||||||
615
src/Obj/Base/RoadObject/index-直接连接.js
Normal file
615
src/Obj/Base/RoadObject/index-直接连接.js
Normal file
@ -0,0 +1,615 @@
|
|||||||
|
/**
|
||||||
|
* @description 道路
|
||||||
|
*/
|
||||||
|
import Dialog from '../../Element/Dialog';
|
||||||
|
import { html } from "./_element";
|
||||||
|
import EventBinding from '../../Element/Dialog/eventBinding';
|
||||||
|
import Base from "../index";
|
||||||
|
import { syncData } from '../../../Global/MultiViewportMode'
|
||||||
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
||||||
|
|
||||||
|
class Road extends Base {
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param sdk
|
||||||
|
* @description 道路
|
||||||
|
* @param options {object} 道路属性
|
||||||
|
* @param options.name=未命名对象 {string} 名称
|
||||||
|
* @param options.carRoadWidth=2 {number} 车道宽度
|
||||||
|
* @param options.sideWidth=2 {number} 人行道宽度
|
||||||
|
* @param options.positions=[] {array} 道路positions
|
||||||
|
* @param options.roadImage='' {string} 车道贴图
|
||||||
|
* @param options.sideImage='' {string} 人行道贴图
|
||||||
|
* @param Dialog {object} 弹框对象
|
||||||
|
* @param Dialog.confirmCallBack {function} 弹框确认时的回调
|
||||||
|
* */
|
||||||
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
|
super(sdk, options);
|
||||||
|
this.viewer = this.sdk.viewer
|
||||||
|
this.options.name = options.name || '道路'
|
||||||
|
this.options.carRoadWidth = options.carRoadWidth || 10
|
||||||
|
this.options.sideWidth = options.sideWidth || 5
|
||||||
|
this.options.positions = options.positions || []
|
||||||
|
this.options.roadImage = options.roadImage || (this.getSourceRootPath() + '/img/roadPhoto.png')
|
||||||
|
this.options.sideImage = options.sideImage || (this.getSourceRootPath() + '/img/sidePhoto.png')
|
||||||
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
|
this.Dialog = _Dialog
|
||||||
|
this._EventBinding = new EventBinding()
|
||||||
|
this._elms = {};
|
||||||
|
this.positionArea = []
|
||||||
|
this.positions = []
|
||||||
|
this.lineEntity = ''
|
||||||
|
|
||||||
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
|
Road.create(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建道路
|
||||||
|
static create(that) {
|
||||||
|
let positions = []
|
||||||
|
that.options.positions.forEach(v => {
|
||||||
|
positions.push(new Cesium.Cartesian3.fromDegrees(v.lng, v.lat, v.alt))
|
||||||
|
})
|
||||||
|
|
||||||
|
let area = [[], [], []]
|
||||||
|
area[1] = that.createLineBufferPolygon2(positions, that.options.carRoadWidth / 2)
|
||||||
|
area[0] = that.createLineBufferPolygonSide(area[1][2], -that.options.sideWidth)
|
||||||
|
area[2] = that.createLineBufferPolygonSide(area[1][1], that.options.sideWidth)
|
||||||
|
|
||||||
|
if (that.viewer.entities.getById(that.options.id)) {
|
||||||
|
that.viewer.entities.getById(that.options.id)._children.forEach((item) => {
|
||||||
|
that.viewer.entities.remove(item);
|
||||||
|
});
|
||||||
|
that.viewer.entities.remove(that.viewer.entities.getById(that.options.id))
|
||||||
|
}
|
||||||
|
that.lineEntity = that.viewer.entities.add(new Cesium.Entity({ id: that.options.id, show: that.options.show }))
|
||||||
|
|
||||||
|
const myImg = new Image()
|
||||||
|
myImg.src = that.options.roadImage
|
||||||
|
myImg.onload = function () {
|
||||||
|
area[1][0].forEach((item, index) => {
|
||||||
|
that.viewer.entities.add({
|
||||||
|
// id: that.options.id,
|
||||||
|
parent: that.lineEntity,
|
||||||
|
polygon: {
|
||||||
|
hierarchy: new Cesium.PolygonHierarchy(item),
|
||||||
|
material: new Cesium.ImageMaterialProperty({
|
||||||
|
image: that.options.roadImage,
|
||||||
|
transparent: true,// 如果图片有透明部分,需要设置为 true
|
||||||
|
repeat: that.calculateTextureRepeat(item, myImg)
|
||||||
|
}),
|
||||||
|
stRotation: that.calculateRoadAngle(positions[index], positions[index + 1])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const myImg2 = new Image()
|
||||||
|
myImg2.src = that.options.sideImage
|
||||||
|
myImg2.onload = function () {
|
||||||
|
area[0].forEach((item, index) => {
|
||||||
|
that.viewer.entities.add({
|
||||||
|
parent: that.lineEntity,
|
||||||
|
polygon: {
|
||||||
|
hierarchy: new Cesium.PolygonHierarchy(item),
|
||||||
|
material: new Cesium.ImageMaterialProperty({
|
||||||
|
image: that.options.sideImage,
|
||||||
|
transparent: true,// 如果图片有透明部分,需要设置为 true
|
||||||
|
repeat: that.calculateTextureRepeat(item, myImg2)
|
||||||
|
}),
|
||||||
|
stRotation: that.calculateRoadAngle(positions[index], positions[index + 1])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
area[2].forEach((item, index) => {
|
||||||
|
that.viewer.entities.add({
|
||||||
|
polygon: {
|
||||||
|
hierarchy: new Cesium.PolygonHierarchy(item),
|
||||||
|
material: new Cesium.ImageMaterialProperty({
|
||||||
|
image: that.options.sideImage,
|
||||||
|
transparent: true,// 如果图片有透明部分,需要设置为 true
|
||||||
|
repeat: that.calculateTextureRepeat(item, myImg2)
|
||||||
|
}),
|
||||||
|
stRotation: that.calculateRoadAngle(positions[index], positions[index + 1])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
getArr(arr1, arr2) {
|
||||||
|
arr2 = arr2.reverse()
|
||||||
|
let polygon = []
|
||||||
|
for (let index = 0; index < arr1.length - 1; index++) {
|
||||||
|
polygon.push([arr1[index], arr1[index + 1], arr2[index + 1], arr2[index]])
|
||||||
|
}
|
||||||
|
return polygon
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateRoadAngle(startPoint, endPoint) {
|
||||||
|
// 1. 获取地表法向量
|
||||||
|
const normal = Cesium.Ellipsoid.WGS84.geodeticSurfaceNormal(startPoint);
|
||||||
|
|
||||||
|
// 2. 构建精确ENU坐标系
|
||||||
|
const enuMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(startPoint, undefined, normal);
|
||||||
|
const inverseMatrix = Cesium.Matrix4.inverse(enuMatrix, new Cesium.Matrix4());
|
||||||
|
|
||||||
|
// 3. 转换终点并计算水平向量
|
||||||
|
const localEnd = Cesium.Matrix4.multiplyByPoint(inverseMatrix, endPoint, new Cesium.Cartesian3());
|
||||||
|
const horizontalVec = new Cesium.Cartesian2(localEnd.x, localEnd.y);
|
||||||
|
Cesium.Cartesian2.normalize(horizontalVec, horizontalVec);
|
||||||
|
|
||||||
|
const north = new Cesium.Cartesian2(1, 0);
|
||||||
|
|
||||||
|
const angle = Cesium.Cartesian2.angleBetween(north, horizontalVec);
|
||||||
|
const cross = Cesium.Cartesian2.cross(north, horizontalVec, new Cesium.Cartesian2());
|
||||||
|
return cross < 0 ? angle : -angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
calculatePolygonOrientation(positions) {
|
||||||
|
|
||||||
|
// 假设 position 是 Cesium.Cartesian3 对象,表示地球上的某个点
|
||||||
|
var position = positions[0]
|
||||||
|
// 获取东、北、上坐标系
|
||||||
|
var eastNorthUp = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||||
|
// northAxis 是北方向向量
|
||||||
|
var northAxis = eastNorthUp.getColumn(1, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(northAxis, northAxis);
|
||||||
|
|
||||||
|
const direction = Cesium.Cartesian3.subtract(positions[0], positions[1], new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(direction, direction);
|
||||||
|
|
||||||
|
|
||||||
|
const dot = Cesium.Cartesian3.dot(northAxis, direction);
|
||||||
|
const magA = Cesium.Cartesian3.magnitude(northAxis);
|
||||||
|
const magB = Cesium.Cartesian3.magnitude(direction);
|
||||||
|
return Math.acos(dot / (magA * magB));
|
||||||
|
}
|
||||||
|
calculateTextureRepeat(polygonPositions, textureSize, meterPerPixel = 0.01) {
|
||||||
|
// 验证纹理尺寸
|
||||||
|
if (!textureSize.width || !textureSize.height) {
|
||||||
|
throw new Error('Texture size must contain width and height in pixels');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建多边形几何体
|
||||||
|
const geometry = Cesium.PolygonGeometry.createGeometry(
|
||||||
|
new Cesium.PolygonGeometry({
|
||||||
|
polygonHierarchy: new Cesium.PolygonHierarchy(polygonPositions),
|
||||||
|
vertexFormat: Cesium.VertexFormat.POSITION_ONLY
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// 计算多边形面积(平方米)
|
||||||
|
let area = 0;
|
||||||
|
const indices = geometry.indices;
|
||||||
|
const positions = geometry.attributes.position.values;
|
||||||
|
for (let i = 0; i < indices.length; i += 3) {
|
||||||
|
const i0 = indices[i] * 3;
|
||||||
|
const i1 = indices[i + 1] * 3;
|
||||||
|
const i2 = indices[i + 2] * 3;
|
||||||
|
|
||||||
|
const p0 = new Cesium.Cartesian3(positions[i0], positions[i0 + 1], positions[i0 + 2]);
|
||||||
|
const p1 = new Cesium.Cartesian3(positions[i1], positions[i1 + 1], positions[i1 + 2]);
|
||||||
|
const p2 = new Cesium.Cartesian3(positions[i2], positions[i2 + 1], positions[i2 + 2]);
|
||||||
|
|
||||||
|
const cross = Cesium.Cartesian3.cross(
|
||||||
|
Cesium.Cartesian3.subtract(p1, p0, new Cesium.Cartesian3()),
|
||||||
|
Cesium.Cartesian3.subtract(p2, p0, new Cesium.Cartesian3()),
|
||||||
|
new Cesium.Cartesian3()
|
||||||
|
);
|
||||||
|
area += Cesium.Cartesian3.magnitude(cross) * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将像素尺寸转换为实际尺寸(平方米)
|
||||||
|
const textureWidthMeters = textureSize.width * meterPerPixel;
|
||||||
|
const textureHeightMeters = textureSize.height * meterPerPixel;
|
||||||
|
const textureArea = textureWidthMeters * textureHeightMeters;
|
||||||
|
|
||||||
|
// 计算各轴向重复次数
|
||||||
|
const repeatX = Math.sqrt(area) / textureWidthMeters;
|
||||||
|
const repeatY = Math.sqrt(area) / textureHeightMeters;
|
||||||
|
|
||||||
|
return new Cesium.Cartesian2(Math.max(1, Math.ceil(repeatX)), 1.0);
|
||||||
|
}
|
||||||
|
swapLastElements(arr1, arr2) {
|
||||||
|
const last = arr1[arr1.length - 1]
|
||||||
|
const first = arr2[0]
|
||||||
|
arr1[arr1.length - 1] = first
|
||||||
|
arr2[0] = last
|
||||||
|
|
||||||
|
return [arr1, arr2];
|
||||||
|
}
|
||||||
|
createLineBufferPolygonSide(positions, width) {
|
||||||
|
let area = []
|
||||||
|
for (let i = 0; i < positions.length - 1; i++) {
|
||||||
|
const start = positions[i];
|
||||||
|
const end = positions[i + 1];
|
||||||
|
|
||||||
|
const dir = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(dir, dir);
|
||||||
|
|
||||||
|
// 获取垂直向量(基于Z轴)
|
||||||
|
const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perp, perp);
|
||||||
|
|
||||||
|
// 生成偏移向量
|
||||||
|
const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3());
|
||||||
|
let point1 = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3())
|
||||||
|
let point3 = Cesium.Cartesian3.add(end, offset, new Cesium.Cartesian3())
|
||||||
|
|
||||||
|
i == positions.length - 2 ? area.push(start, point1, end, point3) : area.push(start, point1)
|
||||||
|
}
|
||||||
|
let arr = []
|
||||||
|
for (let i = 0; i < area.length - 2; i += 2) {
|
||||||
|
arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]])
|
||||||
|
}
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
createLineBufferPolygon2(positions, width) {
|
||||||
|
let area = []
|
||||||
|
let leftPositions = [];
|
||||||
|
let rightPositions = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < positions.length - 1; i++) {
|
||||||
|
const start = positions[i];
|
||||||
|
// const end = positions[i + 1] || positions[i - 1];
|
||||||
|
const end = positions[i + 1];
|
||||||
|
|
||||||
|
const dir = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(dir, dir);
|
||||||
|
|
||||||
|
// 获取垂直向量(基于Z轴)
|
||||||
|
const perp = Cesium.Cartesian3.cross(dir, Cesium.Cartesian3.UNIT_Z, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perp, perp);
|
||||||
|
|
||||||
|
|
||||||
|
// 生成偏移向量
|
||||||
|
const offset = Cesium.Cartesian3.multiplyByScalar(perp, width, new Cesium.Cartesian3());
|
||||||
|
const offset2 = Cesium.Cartesian3.multiplyByScalar(perp, -width, new Cesium.Cartesian3());
|
||||||
|
let point1 = Cesium.Cartesian3.add(start, offset, new Cesium.Cartesian3())
|
||||||
|
let point2 = Cesium.Cartesian3.add(start, offset2, new Cesium.Cartesian3())
|
||||||
|
let point3 = Cesium.Cartesian3.add(end, offset, new Cesium.Cartesian3())
|
||||||
|
let point4 = Cesium.Cartesian3.add(end, offset2, new Cesium.Cartesian3())
|
||||||
|
|
||||||
|
if (i == positions.length - 2) {
|
||||||
|
area.push(point1, point2, point3, point4)
|
||||||
|
rightPositions.push(point1)
|
||||||
|
leftPositions.push(point2)
|
||||||
|
leftPositions.push(point4)
|
||||||
|
rightPositions.push(point3)
|
||||||
|
} else {
|
||||||
|
area.push(point1, point2)
|
||||||
|
rightPositions.push(point1)
|
||||||
|
leftPositions.push(point2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let arr = []
|
||||||
|
for (let i = 0; i < area.length - 2; i += 2) {
|
||||||
|
arr.push([area[i], area[i + 1], area[i + 3], area[i + 2]])
|
||||||
|
}
|
||||||
|
return [arr, rightPositions, leftPositions]
|
||||||
|
}
|
||||||
|
createLineBufferPolygon(viewer, positions, width) {
|
||||||
|
// 计算每个线段的左右偏移点
|
||||||
|
const leftPositions = [];
|
||||||
|
const rightPositions = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < positions.length; i++) {
|
||||||
|
const start = positions[i];
|
||||||
|
const end = positions[i + 1] || positions[i - 1];
|
||||||
|
|
||||||
|
// 计算线段方向向量
|
||||||
|
const direction = Cesium.Cartesian3.subtract(end, start, new Cesium.Cartesian3());
|
||||||
|
// const direction = Cesium.Cartesian3.subtract(start, end, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(direction, direction);
|
||||||
|
|
||||||
|
// 计算垂直向量(使用上向量叉积)
|
||||||
|
const up = Cesium.Cartesian3.UNIT_Z;
|
||||||
|
const perpendicular = Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3());
|
||||||
|
Cesium.Cartesian3.normalize(perpendicular, perpendicular);
|
||||||
|
|
||||||
|
// 计算左右偏移点
|
||||||
|
const leftOffset = Cesium.Cartesian3.multiplyByScalar(
|
||||||
|
perpendicular,
|
||||||
|
width,
|
||||||
|
new Cesium.Cartesian3()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (width > 0) {
|
||||||
|
rightPositions.unshift(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3()));
|
||||||
|
} else if (width < 0) {
|
||||||
|
rightPositions.push(Cesium.Cartesian3.add(start, leftOffset, new Cesium.Cartesian3()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return rightPositions
|
||||||
|
}
|
||||||
|
|
||||||
|
get carRoadWidth() {
|
||||||
|
return this.options.carRoadWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
set carRoadWidth(v) {
|
||||||
|
this.options.carRoadWidth = v
|
||||||
|
Road.create(this)
|
||||||
|
|
||||||
|
}
|
||||||
|
get sideWidth() {
|
||||||
|
return this.options.sideWidth
|
||||||
|
}
|
||||||
|
set sideWidth(v) {
|
||||||
|
this.options.sideWidth = v
|
||||||
|
Road.create(this)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description 编辑框
|
||||||
|
* @param state=false {boolean} 状态: true打开, false关闭
|
||||||
|
*/
|
||||||
|
async edit(state = false) {
|
||||||
|
let _this = this
|
||||||
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
|
||||||
|
if (this._DialogObject && this._DialogObject.close) {
|
||||||
|
this._DialogObject.close()
|
||||||
|
this._DialogObject = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
this._DialogObject = await new Dialog(this.sdk, this.originalOptions, {
|
||||||
|
title: '道路属性', left: '180px', top: '100px',
|
||||||
|
confirmCallBack: (options) => {
|
||||||
|
this.name = this.name.trim()
|
||||||
|
if (!this.name) {
|
||||||
|
this.name = '道路'
|
||||||
|
}
|
||||||
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
|
this._DialogObject.close()
|
||||||
|
this.Dialog.confirmCallBack && this.Dialog.confirmCallBack(this.originalOptions)
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
syncSplitData(this.sdk, this.options.id)
|
||||||
|
},
|
||||||
|
resetCallBack: () => {
|
||||||
|
this.reset()
|
||||||
|
this.Dialog.resetCallBack && this.Dialog.resetCallBack()
|
||||||
|
},
|
||||||
|
closeCallBack: () => {
|
||||||
|
this.reset()
|
||||||
|
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
|
||||||
|
},
|
||||||
|
showCallBack: (show) => {
|
||||||
|
this.show = show
|
||||||
|
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
||||||
|
}
|
||||||
|
}, true)
|
||||||
|
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' road-surface'
|
||||||
|
let contentElm = document.createElement('div');
|
||||||
|
contentElm.innerHTML = html()
|
||||||
|
this._DialogObject.contentAppChild(contentElm)
|
||||||
|
|
||||||
|
|
||||||
|
// 下拉选项
|
||||||
|
// let heightModeData = [
|
||||||
|
// {
|
||||||
|
// name: '海拔高度',
|
||||||
|
// value: '海拔高度',
|
||||||
|
// key: '0',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: '相对地表',
|
||||||
|
// value: '相对地表',
|
||||||
|
// key: '1',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: '依附模型',
|
||||||
|
// value: '依附模型',
|
||||||
|
// key: '2',
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// let heightModeObject = legp(
|
||||||
|
// this._DialogObject._element.content.getElementsByClassName(
|
||||||
|
// 'road-box'
|
||||||
|
// )[0],
|
||||||
|
// '.road-type'
|
||||||
|
// )
|
||||||
|
// if (heightModeObject) {
|
||||||
|
// heightModeObject.legp_search(heightModeData)
|
||||||
|
// let heightModeDataLegpElm = this._DialogObject._element.content
|
||||||
|
// .getElementsByClassName('road-type')[0]
|
||||||
|
// .getElementsByTagName('input')[0]
|
||||||
|
// for (let i = 0; i < heightModeData.length; i++) {
|
||||||
|
// if (heightModeData[i].key == this.heightMode) {
|
||||||
|
// heightModeDataLegpElm.value = heightModeData[i].value
|
||||||
|
// heightModeObject.legp_searchActive(
|
||||||
|
// heightModeData[i].value
|
||||||
|
// )
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// heightModeDataLegpElm.addEventListener('input', () => {
|
||||||
|
// for (let i = 0; i < heightModeData.length; i++) {
|
||||||
|
// if (heightModeData[i].value === heightModeDataLegpElm.value) {
|
||||||
|
// this.heightMode = heightModeData[i].key
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
|
||||||
|
// this._elms.height = heightElm
|
||||||
|
// this._elms.heightBox = heightBoxElm
|
||||||
|
// this._elms.heightMode = heightModeDataLegpElm
|
||||||
|
// this._elms.heightConfirm = heightConfirmElm
|
||||||
|
// this._elms.heightModeObject = heightModeObject
|
||||||
|
|
||||||
|
// heightConfirmElm.addEventListener('click', () => {
|
||||||
|
// this.positionEditing = false
|
||||||
|
// for (let i = 0; i < this.options.positions.length; i++) {
|
||||||
|
// this.options.positions[i].alt = Number((this.options.positions[i].alt + Number(heightElm.value)).toFixed(2))
|
||||||
|
// this._elms.alt[i].innerHTML = this.options.positions[i].alt
|
||||||
|
// }
|
||||||
|
// let fromDegreesArray = this.renewPositions(this.options.positions)
|
||||||
|
// this.entity.polyline.positions = Cesium.Cartesian3.fromDegreesArrayHeights(
|
||||||
|
// fromDegreesArray
|
||||||
|
// )
|
||||||
|
|
||||||
|
// this.positionEditing = false
|
||||||
|
// PolylineObject.closeNodeEdit(this)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let all_elm = contentElm.getElementsByTagName("*")
|
||||||
|
this._EventBinding.on(this, all_elm)
|
||||||
|
this._elms = this._EventBinding.element
|
||||||
|
} else {
|
||||||
|
// if (this._element_style) {
|
||||||
|
// document.getElementsByTagName('head')[0].removeChild(this._element_style)
|
||||||
|
// this._element_style = null
|
||||||
|
// }
|
||||||
|
// if (this._DialogObject && this._DialogObject.remove) {
|
||||||
|
// this._DialogObject.remove()
|
||||||
|
// this._DialogObject = null
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
if (!this.viewer.entities.getById(this.options.id)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.name = this.originalOptions.name
|
||||||
|
this.carRoadWidth = this.originalOptions.carRoadWidth
|
||||||
|
this.sideWidth = this.originalOptions.sideWidth
|
||||||
|
this.positions = this.originalOptions.positions
|
||||||
|
this.roadImage = this.originalOptions.roadImage
|
||||||
|
this.sideImage = this.originalOptions.sideImage
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 飞到对应实体
|
||||||
|
*/
|
||||||
|
async flyTo(options = {}) {
|
||||||
|
setActiveViewer(0)
|
||||||
|
closeRotateAround(this.sdk)
|
||||||
|
closeViewFollow(this.sdk)
|
||||||
|
|
||||||
|
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
|
||||||
|
let orientation = {
|
||||||
|
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
|
||||||
|
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let lng = this.options.customView.relativePosition.lng
|
||||||
|
let lat = this.options.customView.relativePosition.lat
|
||||||
|
let alt = this.options.customView.relativePosition.alt
|
||||||
|
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
|
||||||
|
let position = { lng: 0, lat: 0 }
|
||||||
|
if (this.options.position) {
|
||||||
|
position = { ...this.options.position }
|
||||||
|
}
|
||||||
|
else if (this.options.positions) {
|
||||||
|
position = { ...this.options.positions[0] }
|
||||||
|
}
|
||||||
|
else if (this.options.center) {
|
||||||
|
position = { ...this.options.center }
|
||||||
|
}
|
||||||
|
else if (this.options.start) {
|
||||||
|
position = { ...this.options.start }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.options.hasOwnProperty('lng')) {
|
||||||
|
position.lng = this.options.lng
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('lat')) {
|
||||||
|
position.lat = this.options.lat
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('alt')) {
|
||||||
|
position.alt = this.options.alt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果没有高度值,则获取紧贴高度计算
|
||||||
|
// if (!position.hasOwnProperty('alt')) {
|
||||||
|
// position.alt = await this.getClampToHeight(position)
|
||||||
|
// }
|
||||||
|
lng = this.options.customView.relativePosition.lng + position.lng
|
||||||
|
lat = this.options.customView.relativePosition.lat + position.lat
|
||||||
|
alt = this.options.customView.relativePosition.alt + position.alt
|
||||||
|
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
this.sdk.viewer.camera.flyTo({
|
||||||
|
destination: destination,
|
||||||
|
orientation: orientation
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let positionArray = []
|
||||||
|
for (let i = 0; i < this.positions.length; i++) {
|
||||||
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
|
this.positions[i][0],
|
||||||
|
this.positions[i][1],
|
||||||
|
this.options.height + this.options.heightDifference / 2
|
||||||
|
)
|
||||||
|
positionArray.push(a.x, a.y, a.z)
|
||||||
|
}
|
||||||
|
let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray)
|
||||||
|
this.viewer.camera.flyToBoundingSphere(BoundingSphere, {
|
||||||
|
offset: {
|
||||||
|
heading: Cesium.Math.toRadians(0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(-20.0),
|
||||||
|
roll: Cesium.Math.toRadians(0.0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSphere() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
// entity没有加载完成时 state 不会等于0 所以设置定时器直到获取到为止
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const sphere = new Cesium.BoundingSphere()
|
||||||
|
const state = this.sdk.viewer._dataSourceDisplay.getBoundingSphere(
|
||||||
|
this.viewer.entities.getById(this.options.id),
|
||||||
|
false,
|
||||||
|
sphere
|
||||||
|
)
|
||||||
|
if (state === Cesium.BoundingSphereState.DONE) {
|
||||||
|
clearInterval(interval)
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
async remove() {
|
||||||
|
this.positions = []
|
||||||
|
this.lineEntity = null
|
||||||
|
|
||||||
|
if (this.viewer.entities.getById(this.options.id)) {
|
||||||
|
this.viewer.entities.getById(this.options.id)._children.forEach((item) => {
|
||||||
|
this.viewer.entities.remove(item);
|
||||||
|
});
|
||||||
|
this.viewer.entities.remove(this.viewer.entities.getById(this.options.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._DialogObject && !this._DialogObject.isDestroy) {
|
||||||
|
this._DialogObject.close()
|
||||||
|
this._DialogObject = null
|
||||||
|
}
|
||||||
|
await this.sdk.removeIncetance(this.options.id)
|
||||||
|
await syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
flicker() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Road
|
||||||
1023
src/Obj/Base/RoadObject/index-面大小一致.js
Normal file
1023
src/Obj/Base/RoadObject/index-面大小一致.js
Normal file
File diff suppressed because it is too large
Load Diff
1207
src/Obj/Base/RoadObject/index.js
Normal file
1207
src/Obj/Base/RoadObject/index.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,35 +19,69 @@ class SectorObject extends Base {
|
|||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @description 创建扇形
|
* @description 创建扇形
|
||||||
|
* @param sdk
|
||||||
* @param options {object} 扇形属性
|
* @param options {object} 扇形属性
|
||||||
* @param options.id {string} 标注id
|
* @param options.id {string} 标注id
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color="rgba(255, 0, 0, 0.5)" {string} 颜色
|
||||||
* @param options.center {object} 位置
|
* @param options.center {object} 位置
|
||||||
* @param options.center.lng {object} 经度
|
* @param options.center.lng {number} 经度
|
||||||
* @param options.center.lat {object} 维度
|
* @param options.center.lat {number} 纬度
|
||||||
|
* @param options.center.alt {number} 高度
|
||||||
* @param options.radius=10 {number} 半径
|
* @param options.radius=10 {number} 半径
|
||||||
* @param options.startAngle=10 {number} 起始方向
|
* @param options.startAngle=10 {number} 起始方向
|
||||||
* @param options.endAngle=0 {number} 结束方向
|
* @param options.endAngle=0 {number} 结束方向
|
||||||
* @param options.line {object} 边框
|
* @param options.line {object} 边框
|
||||||
* @param options.line.width=2 {string} 边框宽
|
* @param options.line.width=3 {number} 边框宽
|
||||||
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||||
* @param options.label {object} 标注
|
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
*/
|
*/
|
||||||
constructor(sdk, options = {}) {
|
constructor(sdk, options = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "rgba(255, 0, 0, 0.5)"
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10
|
this.options.semiMinorAxis = (options.semiMinorAxis || options.semiMinorAxis === 0) ? options.semiMinorAxis : 10
|
||||||
this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20
|
this.options.semiMajorAxis = (options.semiMajorAxis || options.semiMajorAxis === 0) ? options.semiMajorAxis : 20
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.center = options.center || {}
|
this.options.center = options.center || {}
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
options.label = options.label || {}
|
options.label = options.label || {}
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
@ -60,8 +94,8 @@ class SectorObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -226,32 +260,32 @@ class SectorObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
this.entity.polyline.width = this.lineWidth
|
this.entity.polyline.width = this.lineWidth
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.color = c
|
this.color = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.color[i] = colorPicker
|
this._elms.color[i] = colorPicker
|
||||||
@ -263,25 +297,25 @@ class SectorObject extends Base {
|
|||||||
return this.options.line.color
|
return this.options.line.color
|
||||||
}
|
}
|
||||||
set lineColor(v) {
|
set lineColor(v) {
|
||||||
this.options.line.color = v
|
this.options.line.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polyline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(this.options.line.color)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.line.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
this.lineColor = c
|
this.lineColor = c
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,0,0,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.lineColor[i] = lineColorPicker
|
this._elms.lineColor[i] = lineColorPicker
|
||||||
@ -293,10 +327,10 @@ class SectorObject extends Base {
|
|||||||
return this.options.line.width
|
return this.options.line.width
|
||||||
}
|
}
|
||||||
set lineWidth(v) {
|
set lineWidth(v) {
|
||||||
this.options.line.width = v
|
this.options.line.width = ((v || v === 0) ? v : 3)
|
||||||
this.entity.polyline.width = v
|
this.entity.polyline.width = this.options.line.width
|
||||||
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
this._elms.lineWidth && this._elms.lineWidth.forEach((item) => {
|
||||||
item.value = v
|
item.value = this.options.line.width
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +378,7 @@ class SectorObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -378,7 +412,7 @@ class SectorObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -478,7 +512,7 @@ class SectorObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -489,7 +523,7 @@ class SectorObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -505,7 +539,7 @@ class SectorObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -531,7 +565,7 @@ class SectorObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1175,7 +1209,7 @@ class SectorObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('circle-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('circle-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1189,7 +1223,7 @@ class SectorObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1203,7 +1237,7 @@ class SectorObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1217,7 +1251,7 @@ class SectorObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labellineColorPicker = new ewPlugins('colorpicker', {
|
let labellineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1231,7 +1265,7 @@ class SectorObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1245,7 +1279,7 @@ class SectorObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1855,6 +1889,7 @@ class SectorObject extends Base {
|
|||||||
that.positionEditing = false
|
that.positionEditing = false
|
||||||
if (YJ.Measure.GetMeasureStatus()) {
|
if (YJ.Measure.GetMeasureStatus()) {
|
||||||
} else {
|
} else {
|
||||||
|
let entity
|
||||||
that.event && that.event.destroy()
|
that.event && that.event.destroy()
|
||||||
that.event = new MouseEvent(that.sdk)
|
that.event = new MouseEvent(that.sdk)
|
||||||
YJ.Measure.SetMeasureStatus(true)
|
YJ.Measure.SetMeasureStatus(true)
|
||||||
@ -1865,7 +1900,9 @@ class SectorObject extends Base {
|
|||||||
|
|
||||||
let fromDegreesArray = that.calSector(that.options.center, that.options.radius, that.options.startAngle, that.options.endAngle)
|
let fromDegreesArray = that.calSector(that.options.center, that.options.radius, that.options.startAngle, that.options.endAngle)
|
||||||
let points = []
|
let points = []
|
||||||
|
let endpoint = { ...that.options.center }
|
||||||
let radius = that.options.radius
|
let radius = that.options.radius
|
||||||
|
let moveRadius = null
|
||||||
let options = {
|
let options = {
|
||||||
angle1: that.options.startAngle,
|
angle1: that.options.startAngle,
|
||||||
angle2: that.options.endAngle
|
angle2: that.options.endAngle
|
||||||
@ -1922,6 +1959,19 @@ class SectorObject extends Base {
|
|||||||
that.cartesian3Towgs84(positions[1], that.sdk.viewer),
|
that.cartesian3Towgs84(positions[1], that.sdk.viewer),
|
||||||
that.cartesian3Towgs84(positions[positions.length - 4], that.sdk.viewer)
|
that.cartesian3Towgs84(positions[positions.length - 4], that.sdk.viewer)
|
||||||
]
|
]
|
||||||
|
let objectsToExclude = [...that.sdk.viewer.entities.values]
|
||||||
|
that
|
||||||
|
.getClampToHeight({
|
||||||
|
lng: that.options.center.lng,
|
||||||
|
lat: that.options.center.lat
|
||||||
|
}, objectsToExclude)
|
||||||
|
.then(height => {
|
||||||
|
that.label.position = [
|
||||||
|
that.options.center.lng,
|
||||||
|
that.options.center.lat,
|
||||||
|
height
|
||||||
|
]
|
||||||
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
createNodePoints(positions[1], 'sector-start')
|
createNodePoints(positions[1], 'sector-start')
|
||||||
createNodePoints(positions[positions.length - 4], 'sector-end')
|
createNodePoints(positions[positions.length - 4], 'sector-end')
|
||||||
@ -1955,12 +2005,14 @@ class SectorObject extends Base {
|
|||||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
||||||
}
|
}
|
||||||
that.nodePoints = []
|
that.nodePoints = []
|
||||||
|
createRadiusLine()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
that.event.mouse_move((movement, cartesian) => {
|
that.event.mouse_move((movement, cartesian) => {
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
|
entity && (entity.show = true)
|
||||||
let pos84 = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
let pos84 = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||||
if (selectPoint._type === 'sector-start') {
|
if (selectPoint._type === 'sector-start') {
|
||||||
points[1] = pos84
|
points[1] = pos84
|
||||||
@ -1969,9 +2021,8 @@ class SectorObject extends Base {
|
|||||||
points[2] = pos84
|
points[2] = pos84
|
||||||
}
|
}
|
||||||
options = calculateAangle(points)
|
options = calculateAangle(points)
|
||||||
let pointA = Cesium.Cartesian3.fromDegrees(points[0].lng, points[0].lat, 0);
|
radius = that.computeDistance2([points[0], pos84]);
|
||||||
let pointB = Cesium.Cartesian3.fromDegrees(pos84.lng, pos84.lat, 0);;
|
endpoint = that.cartesian3Towgs84(cartesian, that.viewer)
|
||||||
radius = Cesium.Cartesian3.distance(pointA, pointB);
|
|
||||||
fromDegreesArray = that.calSector(that.options.center, radius, options.angle1, options.angle2)
|
fromDegreesArray = that.calSector(that.options.center, radius, options.angle1, options.angle2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2012,6 +2063,38 @@ class SectorObject extends Base {
|
|||||||
that.nodePoints.push(entity)
|
that.nodePoints.push(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createRadiusLine() {
|
||||||
|
entity = that.sdk.viewer.entities.add(
|
||||||
|
new Cesium.Entity({
|
||||||
|
show: false,
|
||||||
|
position: new Cesium.CallbackProperty((e) => {
|
||||||
|
if (endpoint) {
|
||||||
|
let c = that.computeMidpoint(that.options.center, endpoint)
|
||||||
|
return Cesium.Cartesian3.fromDegrees(c.lng, c.lat, endpoint.alt)
|
||||||
|
} else {
|
||||||
|
return Cesium.Cartesian3()
|
||||||
|
}
|
||||||
|
}, false),
|
||||||
|
label: {
|
||||||
|
text: new Cesium.CallbackProperty((e) => {
|
||||||
|
if (radius > 1000) {
|
||||||
|
return '半径:' + (radius / 1000).toFixed(2) + ' 公里'
|
||||||
|
}
|
||||||
|
return '半径:' + radius + ' 米'
|
||||||
|
}, false),
|
||||||
|
font: '20px Microsoft YaHei',
|
||||||
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
|
scale: 1,
|
||||||
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
||||||
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
fillColor: Cesium.Color.fromCssColorString('#f5ce0a'),
|
||||||
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
that.nodePoints.push(entity)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,25 +22,67 @@ class StraightArrowObject extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @description 直线箭头
|
* @description 直线箭头
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.name {string} 名称
|
* @param options.name {string} 名称
|
||||||
* @param options.color="#36c4ff" {string} 颜色
|
* @param options.color='rgba(255, 0, 0, 0.5)' {string} 颜色
|
||||||
* @param options.height {number} 高度
|
* @param options.height {number} 高度
|
||||||
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
* @param options.heightMode=2{number} 高度模式(0:海拔高度;1:相对地表;2:依附模式)
|
||||||
* @param {Array.<object>} options.positions 坐标数组 [{lon,lat,alt},...]
|
* @param options.areaUnit='平方米' {string} 面积单位
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param options.line {object} 边框
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param options.line.width=2 {string} 边框宽
|
||||||
|
* @param options.line.color="rgba(155, 155, 124, 0.89)" {string} 边框颜色
|
||||||
|
* @param {Array.<object>} options.positions 必填,经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
||||||
|
* @param options.positions[].lng {number} 经度
|
||||||
|
* @param options.positions[].lat {number} 纬度
|
||||||
|
* @param options.positions[].alt {number} 高度
|
||||||
|
* @param options.spreadState=false {boolean} 动画
|
||||||
|
* @param options.loop=false {loop} 动画重复
|
||||||
|
* @param options.spreadTime=3000 {number} 动画持续时长(毫秒)
|
||||||
|
* @param options.label {object} 标签对象
|
||||||
|
* @param options.label.text {string} 标签文本
|
||||||
|
* @param options.label.show {string} 标签显隐
|
||||||
|
* @param options.label.position {string} 标签位置
|
||||||
|
* @param options.label.position {object} 标签位置
|
||||||
|
* @param options.label.position.lng {number} 经度
|
||||||
|
* @param options.label.position.lat {number} 纬度
|
||||||
|
* @param options.label.position.alt {number} 高度
|
||||||
|
* @param options.label.fontSize=20 {number} 字体大小
|
||||||
|
* @param options.label.fontFamily=0 {number} 字体项 0:黑体;1:思源黑体;2:庞门正道标题体;3:数黑体
|
||||||
|
* @param options.label.color=#ffffff {string} 字体颜色
|
||||||
|
* @param options.label.lineWidth=4 {number} 引线宽
|
||||||
|
* @param options.label.lineColor=#00ffff80 {string} 引线颜色
|
||||||
|
* @param options.label.pixelOffset=20 {number} 字体偏移(引线长度)
|
||||||
|
* @param options.label.backgroundColor=['#00ffff80', '#00ffff80'] {array} 背景颜色
|
||||||
|
* @param options.label.scaleByDistance {boolean} 距离缩放
|
||||||
|
* @param options.label.near=2000 {number} 视野缩放最近距离
|
||||||
|
* @param options.label.far=100000 {number} 视野缩放最远距离
|
||||||
|
* @param options.attribute {object} 属性内容
|
||||||
|
* @param options.attribute.link={} {object} 链接
|
||||||
|
* @param options.attribute.link.content=[]] {array} 链接内容
|
||||||
|
* @param options.attribute.link.content[].name {string} 链接名称
|
||||||
|
* @param options.attribute.link.content[].url {string} 链接地址
|
||||||
|
* @param options.richTextContent {string} 富文本内容
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options);
|
super(sdk, options);
|
||||||
this.options.name = options.name || '未命名对象'
|
this.options.name = options.name || '未命名对象'
|
||||||
this.options.color = options.color || "#36c4ff"
|
this.options.color = options.color || "#ff000080"
|
||||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||||
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
this.options.heightMode = (options.heightMode || options.heightMode == 0) ? options.heightMode : 2
|
||||||
this.options.positions = options.positions || []
|
this.options.positions = options.positions || []
|
||||||
this.options.line = options.line || {}
|
this.options.line = options.line || {}
|
||||||
this.options.line.width = this.options.line.width || 2
|
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(155, 155, 124, 0.89)'
|
this.options.line.color = this.options.line.color || 'rgba(255, 0, 0, 1)'
|
||||||
this.options['area-unit'] = options['area-unit'] || '平方米'
|
this.options['area-unit'] = options['area-unit'] || '平方米'
|
||||||
this.entity
|
this.entity
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
@ -60,8 +102,8 @@ class StraightArrowObject extends Base {
|
|||||||
color: options.label.color || '#ffffff',
|
color: options.label.color || '#ffffff',
|
||||||
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
|
||||||
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
|
||||||
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'],
|
backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
|
||||||
lineColor: options.label.lineColor || '#fff000',
|
lineColor: options.label.lineColor || '#00ffff80',
|
||||||
scaleByDistance: options.label.scaleByDistance || false,
|
scaleByDistance: options.label.scaleByDistance || false,
|
||||||
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,
|
||||||
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
far: (options.label.far || options.label.far === 0) ? options.label.far : 100000,
|
||||||
@ -109,24 +151,24 @@ class StraightArrowObject extends Base {
|
|||||||
return this.options.color
|
return this.options.color
|
||||||
}
|
}
|
||||||
set color(v) {
|
set color(v) {
|
||||||
this.options.color = v
|
this.options.color = v || 'rgba(255, 0, 0, 0.5)'
|
||||||
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
if (!this.sdk || !this.sdk.viewer || !this.entity || !this.entity.polygon) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let material = Cesium.Color.fromCssColorString(v)
|
let material = Cesium.Color.fromCssColorString(this.options.color)
|
||||||
if (this.sdk.viewer.scene.mode === 2) {
|
if (this.sdk.viewer.scene.mode === 2) {
|
||||||
material = new Cesium.CustomColorMaterialSource({
|
material = new Cesium.CustomColorMaterialSource({
|
||||||
color: v
|
color: this.options.color
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.entity.polygon.material = material
|
this.entity.polygon.material = material
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
defaultColor: v,
|
defaultColor: this.options.color,
|
||||||
disabled: false,//是否禁止打开颜色选择器
|
disabled: false,//是否禁止打开颜色选择器
|
||||||
openPickerAni: 'opacity',//打开颜色选择器动画
|
openPickerAni: 'opacity',//打开颜色选择器动画
|
||||||
sure: (c) => {
|
sure: (c) => {
|
||||||
@ -247,7 +289,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
this.entity.polyline.material = Cesium.Color.fromCssColorString(v)
|
||||||
if (this._elms.lineColor) {
|
if (this._elms.lineColor) {
|
||||||
this._elms.lineColor.forEach((item, i) => {
|
this._elms.lineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -321,7 +363,7 @@ class StraightArrowObject extends Base {
|
|||||||
}
|
}
|
||||||
set labelShow(v) {
|
set labelShow(v) {
|
||||||
this.options.label.show = v
|
this.options.label.show = v
|
||||||
if (this.show) {
|
if (this.show && !this.showView || this.showView == 3) {
|
||||||
this.label.show = v
|
this.label.show = v
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -355,7 +397,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.label.color = v
|
this.label.color = v
|
||||||
if (this._elms.labelColor) {
|
if (this._elms.labelColor) {
|
||||||
this._elms.labelColor.forEach((item, i) => {
|
this._elms.labelColor.forEach((item, i) => {
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -455,7 +497,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.label.lineColor = v
|
this.label.lineColor = v
|
||||||
if (this._elms.labelLineColor) {
|
if (this._elms.labelLineColor) {
|
||||||
this._elms.labelLineColor.forEach((item, i) => {
|
this._elms.labelLineColor.forEach((item, i) => {
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -466,7 +508,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.labelLineColor = color
|
this.labelLineColor = color
|
||||||
},//点击确认按钮事件回调
|
},//点击确认按钮事件回调
|
||||||
clear: () => {
|
clear: () => {
|
||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(0,255,255,0.5)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
this._elms.labelLineColor[i] = lineColorPicker
|
this._elms.labelLineColor[i] = lineColorPicker
|
||||||
@ -482,7 +524,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
this.label.backgroundColor = [v, this.label.backgroundColor[1]]
|
||||||
if (this._elms.labelBackgroundColorStart) {
|
if (this._elms.labelBackgroundColorStart) {
|
||||||
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
this._elms.labelBackgroundColorStart.forEach((item, i) => {
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -508,7 +550,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
this.label.backgroundColor = [this.label.backgroundColor[0], v]
|
||||||
if (this._elms.labelBackgroundColorEnd) {
|
if (this._elms.labelBackgroundColorEnd) {
|
||||||
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
this._elms.labelBackgroundColorEnd.forEach((item, i) => {
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1178,7 +1220,7 @@ class StraightArrowObject extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
let tabsElm = new cy_tabs('assemble-object-edit-tabs', undefined, this.sdk)
|
let tabsElm = new cy_tabs('assemble-object-edit-tabs', undefined, this.sdk)
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1192,7 +1234,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let linecolorPicker = new ewPlugins('colorpicker', {
|
let linecolorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("lineColor")[0],
|
el: contentElm.getElementsByClassName("lineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1206,7 +1248,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.lineColor = 'rgba(255,255,255,1)'
|
this.lineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1220,7 +1262,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labellineColorPicker = new ewPlugins('colorpicker', {
|
let labellineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -1234,7 +1276,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -1248,7 +1290,7 @@ class StraightArrowObject extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -2075,8 +2117,10 @@ class StraightArrowObject extends Base {
|
|||||||
that.event.gesture_pinck_start(() => { })
|
that.event.gesture_pinck_start(() => { })
|
||||||
if (selectPoint) {
|
if (selectPoint) {
|
||||||
if (!originalPosition) {
|
if (!originalPosition) {
|
||||||
|
if (that.options.positions.length > 2) {
|
||||||
that.options.positions.pop()
|
that.options.positions.pop()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
that.options.positions[selectPoint.index] = originalPosition
|
that.options.positions[selectPoint.index] = originalPosition
|
||||||
}
|
}
|
||||||
|
|||||||
292
src/Obj/Base/TextBox/index.js
Normal file
292
src/Obj/Base/TextBox/index.js
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
/**
|
||||||
|
* 文本框
|
||||||
|
*/
|
||||||
|
import Base from "../index";
|
||||||
|
import { syncData, getSdk } from '../../../Global/MultiViewportMode'
|
||||||
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global'
|
||||||
|
class TextBox extends Base {
|
||||||
|
/**
|
||||||
|
* @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.options = { ...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.handler = undefined
|
||||||
|
this.textDom = undefined
|
||||||
|
this.create(this)
|
||||||
|
this.sdk.addIncetance(this.options.id, this)
|
||||||
|
|
||||||
|
this.callback = callback
|
||||||
|
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
get type() {
|
||||||
|
return 'TextBox'
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(that) {
|
||||||
|
let viewer = that.sdk.viewer
|
||||||
|
// 创建div元素
|
||||||
|
let dom = document.createElement('span');
|
||||||
|
dom.id = that.options.id
|
||||||
|
dom.className = 'popup-textarea'
|
||||||
|
dom.style.zIndex = 1
|
||||||
|
// 创建textarea元素
|
||||||
|
var textarea = document.createElement('textarea');
|
||||||
|
textarea.className = 'textarea'
|
||||||
|
textarea.value = that.options.text;
|
||||||
|
// 设置textarea的属性,例如行数和列数
|
||||||
|
textarea.rows = 6;
|
||||||
|
textarea.style.resize = 'none'
|
||||||
|
// 将textarea添加到div中
|
||||||
|
dom.appendChild(textarea);
|
||||||
|
(!that.options.show) && (dom.style.display = 'none')
|
||||||
|
// 将div添加到body中
|
||||||
|
// document.body.appendChild(dom);
|
||||||
|
|
||||||
|
// 配置CSS样式和内容结构
|
||||||
|
viewer.cesiumWidget.container.appendChild(dom);
|
||||||
|
let posi = Cesium.Cartesian3.fromDegrees(that.options.position.lng, that.options.position.lat, that.options.position.alt)
|
||||||
|
that.handler = function () {
|
||||||
|
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||||
|
viewer.scene, posi
|
||||||
|
);
|
||||||
|
if (position) {
|
||||||
|
let width = dom.clientWidth * 1
|
||||||
|
let height = dom.clientHeight * 1
|
||||||
|
dom.style.left = `${position.x - width / 2}px`;
|
||||||
|
dom.style.top = `${position.y - height}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
viewer.scene.postRender.addEventListener(that.handler);
|
||||||
|
that.textDom = dom;
|
||||||
|
|
||||||
|
}
|
||||||
|
async isClick(posi, id) {
|
||||||
|
let params = [
|
||||||
|
{
|
||||||
|
position: posi
|
||||||
|
},
|
||||||
|
id,
|
||||||
|
null
|
||||||
|
]
|
||||||
|
|
||||||
|
this.clickCallBack({ position: posi }, id, null)
|
||||||
|
}
|
||||||
|
async setHandeler(data) {
|
||||||
|
let that = this
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
that.sdk.viewer.scene.postRender.removeEventListener(that.handler);
|
||||||
|
|
||||||
|
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
||||||
|
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||||
|
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||||
|
|
||||||
|
let height = await that.getClampToHeight({ lng: longitude, lat: latitude })
|
||||||
|
that.position = {
|
||||||
|
lng: longitude,
|
||||||
|
lat: latitude,
|
||||||
|
alt: cartographic.height
|
||||||
|
// alt: height
|
||||||
|
}
|
||||||
|
let posi = Cesium.Cartesian3.fromDegrees(longitude, latitude, cartographic.height)
|
||||||
|
|
||||||
|
that.handler = function () {
|
||||||
|
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||||
|
that.sdk.viewer.scene, posi
|
||||||
|
);
|
||||||
|
if (position) {
|
||||||
|
let width = that.textDom.clientWidth * 1
|
||||||
|
let height = that.textDom.clientHeight * 1
|
||||||
|
that.textDom.style.left = `${position.x - width / 2}px`;
|
||||||
|
that.textDom.style.top = `${position.y - height}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that.sdk.viewer.scene.postRender.addEventListener(that.handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async getwords(words) {
|
||||||
|
this.options.text = words
|
||||||
|
this.callback(this.options)
|
||||||
|
let { sdkP } = getSdk()
|
||||||
|
if (this.sdk === sdkP && sdkP) {//三维
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
else if (sdkP) {//二维
|
||||||
|
sdkP.entityMap.get(this.options.id).text = words
|
||||||
|
sdkP.entityMap.get(this.options.id).twoToThree(this.options.position)
|
||||||
|
} else if (!sdkP) {
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async twoToThree(position) {
|
||||||
|
let that = this
|
||||||
|
that.sdk.viewer.scene.postRender.removeEventListener(that.handler);
|
||||||
|
let posi = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, position.alt)
|
||||||
|
|
||||||
|
that.handler = function () {
|
||||||
|
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||||
|
that.sdk.viewer.scene, posi
|
||||||
|
);
|
||||||
|
if (position) {
|
||||||
|
let width = that.textDom.clientWidth * 1
|
||||||
|
let height = that.textDom.clientHeight * 1
|
||||||
|
that.textDom.style.left = `${position.x - width / 2}px`;
|
||||||
|
that.textDom.style.top = `${position.y - height}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that.sdk.viewer.scene.postRender.addEventListener(that.handler);
|
||||||
|
}
|
||||||
|
async returnFun() {
|
||||||
|
return this.handler
|
||||||
|
}
|
||||||
|
get text() {
|
||||||
|
return this.options.text
|
||||||
|
}
|
||||||
|
set text(val) {
|
||||||
|
this.options.text = val
|
||||||
|
this.textDom.querySelector('textarea').value = val
|
||||||
|
this.callback(this.options)
|
||||||
|
}
|
||||||
|
get onClick() {
|
||||||
|
return this.clickCallBack
|
||||||
|
}
|
||||||
|
set onClick(val) {
|
||||||
|
if (val && typeof val !== 'function') {
|
||||||
|
console.error('val:', val, '不是一个function')
|
||||||
|
} else {
|
||||||
|
this.clickCallBack = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get show() {
|
||||||
|
return this.options.show
|
||||||
|
}
|
||||||
|
set show(v) {
|
||||||
|
this.options.show = v
|
||||||
|
this.textDom && (this.textDom.style.display = v ? 'block' : 'none');
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
get position() {
|
||||||
|
return this.options.position
|
||||||
|
}
|
||||||
|
set position(v) {
|
||||||
|
this.options.position = v
|
||||||
|
}
|
||||||
|
async flyTo(options = {}) {
|
||||||
|
setActiveViewer(0)
|
||||||
|
closeRotateAround(this.sdk)
|
||||||
|
closeViewFollow(this.sdk)
|
||||||
|
|
||||||
|
if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) {
|
||||||
|
let orientation = {
|
||||||
|
heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0),
|
||||||
|
roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
let lng = this.options.customView.relativePosition.lng
|
||||||
|
let lat = this.options.customView.relativePosition.lat
|
||||||
|
let alt = this.options.customView.relativePosition.alt
|
||||||
|
let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
|
||||||
|
let position = { lng: 0, lat: 0 }
|
||||||
|
if (this.options.position) {
|
||||||
|
position = { ...this.options.position }
|
||||||
|
}
|
||||||
|
else if (this.options.position) {
|
||||||
|
position = { ...this.options.position[0] }
|
||||||
|
}
|
||||||
|
else if (this.options.center) {
|
||||||
|
position = { ...this.options.center }
|
||||||
|
}
|
||||||
|
else if (this.options.start) {
|
||||||
|
position = { ...this.options.start }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (this.options.hasOwnProperty('lng')) {
|
||||||
|
position.lng = this.options.lng
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('lat')) {
|
||||||
|
position.lat = this.options.lat
|
||||||
|
}
|
||||||
|
if (this.options.hasOwnProperty('alt')) {
|
||||||
|
position.alt = this.options.alt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果没有高度值,则获取紧贴高度计算
|
||||||
|
// if (!position.hasOwnProperty('alt')) {
|
||||||
|
// position.alt = await this.getClampToHeight(position)
|
||||||
|
// }
|
||||||
|
lng = this.options.customView.relativePosition.lng + position.lng
|
||||||
|
lat = this.options.customView.relativePosition.lat + position.lat
|
||||||
|
alt = this.options.customView.relativePosition.alt + position.alt
|
||||||
|
destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt)
|
||||||
|
this.sdk.viewer.camera.flyTo({
|
||||||
|
destination: destination,
|
||||||
|
orientation: orientation
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let positionArray = []
|
||||||
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
|
this.position.lng,
|
||||||
|
this.position.lat,
|
||||||
|
this.position.alt
|
||||||
|
)
|
||||||
|
positionArray.push(a.x, a.y, a.z)
|
||||||
|
|
||||||
|
let BoundingSphere = Cesium.BoundingSphere.fromVertices(positionArray)
|
||||||
|
this.viewer.camera.flyToBoundingSphere(BoundingSphere, {
|
||||||
|
offset: {
|
||||||
|
heading: Cesium.Math.toRadians(0.0),
|
||||||
|
pitch: Cesium.Math.toRadians(-20.0),
|
||||||
|
roll: Cesium.Math.toRadians(0.0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove() {
|
||||||
|
if (this.handler) {
|
||||||
|
this.sdk.viewer.scene.postRender.removeEventListener(this.handler);
|
||||||
|
this.handler = undefined
|
||||||
|
}
|
||||||
|
if (this.textDom && this.textDom.parentNode) {
|
||||||
|
this.sdk.viewer.cesiumWidget.container.removeChild(this.textDom);
|
||||||
|
}
|
||||||
|
await this.sdk.removeIncetance(this.options.id)
|
||||||
|
syncData(this.sdk, this.options.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
flicker() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TextBox
|
||||||
@ -52,7 +52,7 @@ class Text3D extends Base {
|
|||||||
})
|
})
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -236,7 +236,7 @@ class Text3D extends Base {
|
|||||||
// 创建标签页
|
// 创建标签页
|
||||||
// let tabsElm = new cy_tabs('radar-scan-edit-tabs')
|
// let tabsElm = new cy_tabs('radar-scan-edit-tabs')
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("color")[0],
|
el: contentElm.getElementsByClassName("color")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -250,7 +250,7 @@ class Text3D extends Base {
|
|||||||
this.color = 'rgba(255,255,255,1)'
|
this.color = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelColorPicker = new ewPlugins('colorpicker', {
|
let labelColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelColor")[0],
|
el: contentElm.getElementsByClassName("labelColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -264,7 +264,7 @@ class Text3D extends Base {
|
|||||||
this.labelColor = 'rgba(255,255,255,1)'
|
this.labelColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let lineColorPicker = new ewPlugins('colorpicker', {
|
let lineColorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
el: contentElm.getElementsByClassName("labelLineColor")[0],
|
||||||
size: 'mini',//颜色box类型
|
size: 'mini',//颜色box类型
|
||||||
alpha: true,//是否开启透明度
|
alpha: true,//是否开启透明度
|
||||||
@ -278,7 +278,7 @@ class Text3D extends Base {
|
|||||||
this.labelLineColor = 'rgba(255,255,255,1)'
|
this.labelLineColor = 'rgba(255,255,255,1)'
|
||||||
},//点击清空按钮事件回调
|
},//点击清空按钮事件回调
|
||||||
})
|
})
|
||||||
let labelBackgroundColorStartPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorStartPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
@ -292,7 +292,7 @@ class Text3D extends Base {
|
|||||||
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let labelBackgroundColorEndPicker = new ewPlugins('colorpicker', {
|
let labelBackgroundColorEndPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
|
||||||
size: 'mini',
|
size: 'mini',
|
||||||
alpha: true,
|
alpha: true,
|
||||||
|
|||||||
@ -14,14 +14,27 @@ class GroundText extends Base {
|
|||||||
* @param sdk
|
* @param sdk
|
||||||
* @description 贴地文字
|
* @description 贴地文字
|
||||||
* @param options {object} 属性
|
* @param options {object} 属性
|
||||||
|
* @param options.id {string} 唯一标识
|
||||||
* @param options.show=true {boolean} 显示/隐藏
|
* @param options.show=true {boolean} 显示/隐藏
|
||||||
* @param options.text {string} 文字
|
* @param options.text {string} 文字
|
||||||
* @param options.angle=0 {number} 旋转角度
|
* @param options.angle=0 {number} 旋转角度
|
||||||
* @param options.scale=1 {number} 比例
|
* @param options.scale=1 {number} 缩放比例
|
||||||
* @param {object} options.position 经纬度{lon,lat}
|
* @param options.speed=1 {number} 文字滚动速度
|
||||||
* @param {object} options.positions 经纬度集[{lon,lat}]仅在未定义 position 时有效
|
* @param {object} options.position 位置
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param {number} options.position.lng 经度
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param {number} options.position.lat 纬度
|
||||||
|
* @param {object} options.positions 坐标集[{lon,lat}]仅在未定义 position 时有效
|
||||||
|
* @param options.positions[].lng {number} 经度
|
||||||
|
* @param options.positions[].lat {number} 纬度
|
||||||
|
* @param options.customView {object} 默认视角
|
||||||
|
* @param options.customView.orientation {object} 默认视角方位
|
||||||
|
* @param options.customView.orientation.heading {number} 航向角
|
||||||
|
* @param options.customView.orientation.pitch {number} 俯仰角
|
||||||
|
* @param options.customView.orientation.roll {number} 翻滚角
|
||||||
|
* @param options.customView.relativePosition {object} 视角相对位置
|
||||||
|
* @param options.customView.relativePosition.lng {number} 经度
|
||||||
|
* @param options.customView.relativePosition.lat {number} 纬度
|
||||||
|
* @param options.customView.relativePosition.alt {number} 高度
|
||||||
* */
|
* */
|
||||||
constructor(sdk, options = {}, _Dialog = {}) {
|
constructor(sdk, options = {}, _Dialog = {}) {
|
||||||
super(sdk, options)
|
super(sdk, options)
|
||||||
@ -263,7 +276,7 @@ class GroundText extends Base {
|
|||||||
})
|
})
|
||||||
if (this._elms.color) {
|
if (this._elms.color) {
|
||||||
this._elms.color.forEach((item, i) => {
|
this._elms.color.forEach((item, i) => {
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: item.el,
|
el: item.el,
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -401,7 +414,7 @@ class GroundText extends Base {
|
|||||||
this._elms = this._EventBinding.element
|
this._elms = this._EventBinding.element
|
||||||
|
|
||||||
// 颜色组件
|
// 颜色组件
|
||||||
let colorPicker = new ewPlugins('colorpicker', {
|
let colorPicker = new YJColorPicker({
|
||||||
el: contentElm.getElementsByClassName('color')[0],
|
el: contentElm.getElementsByClassName('color')[0],
|
||||||
size: 'mini', //颜色box类型
|
size: 'mini', //颜色box类型
|
||||||
alpha: true, //是否开启透明度
|
alpha: true, //是否开启透明度
|
||||||
@ -649,7 +662,7 @@ class GroundText extends Base {
|
|||||||
ctx.font = 200 + 'px serif'
|
ctx.font = 200 + 'px serif'
|
||||||
ctx.fillStyle = 'rgba(255, 255, 255, 0)'
|
ctx.fillStyle = 'rgba(255, 255, 255, 0)'
|
||||||
ctx.fillRect(0, 0, maxWidth + 30, 210)
|
ctx.fillRect(0, 0, maxWidth + 30, 210)
|
||||||
ctx.fillStyle = this.options.color
|
ctx.fillStyle = 'rgba(255, 255, 255, 1)'
|
||||||
ctx.font = '200px serif'
|
ctx.font = '200px serif'
|
||||||
ctx.fillText(textArray[i], 0, 210 * (i + 1))
|
ctx.fillText(textArray[i], 0, 210 * (i + 1))
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user