效果
关键代码
const canvasHeight = this.viewer.scene.canvas.height;
const windowPosition = new Cesium.Cartesian2();
Cesium.SceneTransforms.wgs84ToWindowCoordinates(this.viewer.scene, this.position, windowPosition);
this.vmInstance.$el.style.bottom = canvasHeight - windowPosition.y + 70 + "px";
const elWidth = this.vmInstance.$el.offsetWidth;
this.vmInstance.$el.style.left = windowPosition.x + 20 + "px";
if (this.viewer.camera.positionCartographic.height > 4000) {
this.vmInstance.$el.style.display = "none";
} else {
this.vmInstance.$el.style.display = "block";
}
详情参见 Cesium实战项目