三角量测效果
实现
量测是地图工具中比较基础的功能,实现也比较容易。
三角量测稍微需要研究一点,这里提供思路:
1.动态创建三条线段
2.通过直线两端的点计算水平线的另一端坐标
3.动态计算距离并表示
/**
* 三角测量
*/
class MeasureTriangles extends Draw {
constructor(measureInfo, style) {
super(measureInfo)
this._tempLineEntity = new Cesium.Entity()
this._tempLineEntity2 = new Cesium.Entity()
this._positions = []
this._tempPoints = []
this._tempPoints2 = []
this._style = {
...DEF_STYLE,
...style
}
}
_mouseClickHandler(movement) {
//let position = this._viewer.delegate.scene.camera.pickEllipsoid(movement.position, Cesium.Ellipsoid.WGS84)
let position = this._viewer.scene.pickPosition(movement.position);
if(!position)return false
if (this._positions.length == 0) {
this._positions.push(position.clone())
this._positions.push(position.clone())
this._tempPoints.push(position.clone())
t