更改切换二三维代码
This commit is contained in:
parent
57a5a2f79e
commit
6694ce6c51
|
|
@ -373,35 +373,52 @@ async function obtainViewer(id: string, opt?: InitViewerOptions): Promise<Cesium
|
|||
return window.cesView3D[id]?.map;
|
||||
}
|
||||
|
||||
function defined(value: any): boolean {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
function defaultValue(value: any, fallback: any) {
|
||||
return defined(value) ? value : fallback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @description 设置二三维切换
|
||||
* @param {string} viewerID 视图容器id
|
||||
* @param {string} modelType 模式
|
||||
*/
|
||||
function set2DModelOr3DModel(viewerID: any, modelType: any, duration: any, callback: any) {
|
||||
if (!Cesium.defined(viewerID) || !Cesium.defined(modelType))
|
||||
return;
|
||||
function set2DModelOr3DModel(
|
||||
viewerID: any,
|
||||
modelType: any,
|
||||
duration: any,
|
||||
callback: any
|
||||
) {
|
||||
// 替换 Cesium.defined
|
||||
if (!defined(viewerID) || !defined(modelType)) return;
|
||||
|
||||
obtainViewer(viewerID).then((viewer: any) => {
|
||||
if (!Cesium.defined(viewer))
|
||||
return;
|
||||
duration = Cesium.defaultValue(duration, 2.0);
|
||||
if (modelType === '3D') {
|
||||
if (!defined(viewer)) return;
|
||||
|
||||
// 替换 Cesium.Core.defaultValue
|
||||
duration = defaultValue(duration, 2.0);
|
||||
|
||||
if (modelType === "3D") {
|
||||
viewer.scene.morphTo3D(duration);
|
||||
}
|
||||
else if (modelType === '2D') {
|
||||
} else if (modelType === "2D") {
|
||||
viewer.scene.morphTo2D(duration);
|
||||
}
|
||||
else if (modelType === '2.5D') {
|
||||
} else if (modelType === "2.5D") {
|
||||
viewer.scene.morphToColumbusView(duration);
|
||||
}
|
||||
|
||||
if (callback instanceof Function) {
|
||||
setTimeout(() => {
|
||||
callback();
|
||||
}, duration + 1);
|
||||
}, (duration + 1) * 1000); // 注意:duration单位是秒,setTimeout是毫秒!这里你原有代码有BUG
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function updateViewOnZoom(viewer: any, key: any) {
|
||||
// 获取当前镜头位置的笛卡尔坐标
|
||||
let cameraPos = viewer.camera.position;
|
||||
|
|
@ -737,6 +754,7 @@ function controlEntityVisibilityByType(type: any, isShow: any) {
|
|||
console.warn(`无此类型的Entity:${type}`);
|
||||
return;
|
||||
}
|
||||
console.log(entityTypeMap,"2222222222222")
|
||||
// 遍历同类型所有Entity,修改show属性
|
||||
entityTypeMap[type].forEach((entity: any) => {
|
||||
// 同时控制billboard和label的显隐(也可单独控制)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user