diff --git a/src/gis/cesium/map.ts b/src/gis/cesium/map.ts index af3ed7fe..a25700de 100644 --- a/src/gis/cesium/map.ts +++ b/src/gis/cesium/map.ts @@ -373,35 +373,52 @@ async function obtainViewer(id: string, opt?: InitViewerOptions): Promise { - 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的显隐(也可单独控制)