废话不说,直接上代码
/**
* @Description: 二三维联动,二维openlayers,三维Cesium
*/
class Cesium2DLinkage3DUtil {
constructor(mapId = 'map2d-view-compare-map') {
this.mapId = mapId
this.isActive = false
this.isIn2DMapFlag = false;
this.mouseMoveEvent = this.mouseMoveEvent.bind(this)
this.getViewCameraRectrange = this.getViewCameraRectrange.bind(this)
this.changeCenterListener = this.changeCenterListener.bind(this)
}
/**
* 初始化地图容器,插入三维容器的左侧
*/
init2DDiv(){
this.mapDiv = document.createElement('div');
this.mapDiv.setAttribute('id', this.mapId)
this.mapDiv.style.width = '0%';
this.mapDiv.style.height = '100%';
this.mapDiv.style.position = 'relative';
this.mapDiv.style.visibility = 'hidden'
// insertBefore
const viewerContainer = this.viewer.cesiumWidget.container.parentElement.parentElement
viewerContainer.parentNode.insertB