首页 > 解决方案 > ol-cesium:有没有办法在 ol-cesium 中选择一个特征并将其追溯到 openlayers 特征?

问题描述

我有一个 geojson 作为特征向量添加到 openlayer。其属性部分中的所有 geojson 都有一些附加信息,我想在单击 3d 空间中的功能(例如弹出窗口)时显示这些信息。我使用 ol-cesium 覆盖示例创建了一个 pop,但没有办法仅在启用 3d(ol-cesium) 的情况下获取 feature-geojson 属性。是否有任何方法可以获取单击 3d 空间中的功能的功能详细信息?

标签: openlayers-5

解决方案


想通了,我想我必须做一些这样的想法。

private getOlFeatureFromMouseLocationInOLCS(cesiumMouseEvent: any): OlFeature | undefined {

if (cesiumMouseEvent.position.x === 0 && cesiumMouseEvent.position.y === 0) {
    return;
}
 /**
 //hoping the below two lines have bee defined early on . 
 this._ol3d = new OLCesium({ map: this._currentMap });
 this.scene = this._ol3d.getCesiumScene();
 **/
 const pickedFeature = this.scene.pick(cesiumMouseEvent.position);
 let olFeature: OlFeature;
 if (pickedFeature.primitive) {
    olFeature = (pickedFeature.primitive.olFeature)?pickedFeature.primitive.olFeature as OlFeature : undefined;
} else {
    olFeature = undefined;
}
 return olFeature;
}

推荐阅读