suerprisePlus
2024-08-05 30e393df7b1d89c4172a7f4bec6e80e2dc00c373
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import mapConfig from './mapConfig';
import mapData from './mapData';
import mapServer from './mapServe';
 
const mapInit = {
    async Init() {
        console.log(location)
        window.earthCtrl = new SmartEarth.EarthCtrl('sdkContainer', {
            // 隐藏默认底图
            defaultImagery: false,
            // 隐藏logo
            printLog: false,
            // sceneMode: SmartEarth.Cesium.SceneMode.SCENE2D
            StaticFileBaseUrl: '/CimSDK/',
        });
        // 初始化Cesium
        window.Cesium = SmartEarth.Cesium;
        // 初始化Viewer
        window.Viewer = earthCtrl.viewer;
        //设置地球颜色
        Viewer.scene.globe.baseColor = Cesium.Color.fromCssColorString('#A9A9A9');
        // 地形加载
        const terrain = config.terrain;
        if (terrain.isShow && terrain.isUrl) {
            const terrainProvider = await Cesium.CesiumTerrainProvider.fromUrl(terrain.isUrl, {
                requestWaterMask: true,
                requestVertexNormals: true,
            });
 
            Viewer.terrainProvider = terrainProvider;
        }
        // 默认设置底图
        this.addImageLayer();
    },
    addImageLayer() {
        const baseLayer = mapData.baseLayer;
        // 添加天地图底图
        mapServer.addLayer({
            serveType: 'tdMap',
            url: baseLayer.sUrl + baseLayer.vecLayer + baseLayer.lUrl,
        });
        // 添加天地图标注
        mapServer.addLayer({
            serveType: 'tdMap',
            url: baseLayer.sUrl + baseLayer.cvaLayer + baseLayer.lUrl,
        });
        // 初始化视角
        this.setdefaultPerspective();
    },
    setdefaultPerspective() {
        mapConfig.sertCameraTo(mapData.defaultPerspective);
    },
};
export default mapInit;