html
<div id="map-container"></div>
<div id="map-infowindow1">
...
</div>
<div id="map-infowindow2">
...
</div>
js
// 地图浮框
class Infowindow {
_element: HTMLElement; // 浮框DOM元素
_offsetX: number; // X轴偏移量
_offsetY: number; // Y轴偏移量
_entityId: string;
_viewer: Cesium.Viewer;
constructor (viewer: Cesium.Viewer, element: HTMLElement, offsetX = 0, offsetY=0) {
this._viewer = viewer;
this._element = element;
this._offsetX = offsetX;
this._offsetY = offsetY;
}
set entityId (entityId: string) {
this._entityId = entityId;
}
get viewer (): Cesium.Viewer {
return this._viewer;
}
get entity (): Cesium.Entity {
return this._viewer.entities.getById(this._entityId);
}
}
// 初始化地图
const viewer = new Cesium.Viewer('map-container');
// 创建