viewer_s3m_wz.vue 3.26 KB
<!--
 * @Author: jiangbotao
 * @Date: 2019-12-03 22:52:56
 * @LastEditors: jiangbotao
 * @LastEditTime: 2019-12-04 22:23:44
 * @FilePath: \superglobevue\src\components\viewer.vue
 -->
<template>
    <div>
		<div id="cesiumContainer" v-bind:style="styleObject"></div>
		<div id='loadingbar' class="spinner">
			<div class="spinner-container container1">
				<div class="circle1"></div>
				<div class="circle2"></div>
				<div class="circle3"></div>
				<div class="circle4"></div>
			</div>
			<div class="spinner-container container2">
				<div class="circle1"></div>
				<div class="circle2"></div>
				<div class="circle3"></div>
				<div class="circle4"></div>
			</div>
			<div class="spinner-container container3">
				<div class="circle1"></div>
				<div class="circle2"></div>
				<div class="circle3"></div>
				<div class="circle4"></div>
			</div>
		</div>
	</div>
</template>

<script>
import URL_CONFIG from "./../config/urlConfig.vue";
const Cesium = window.Cesium;
export default {
    data: function() {
        return {
            styleObject: {
                width: "100%",
                position: "absolute",
                top: "0px",
                bottom: "0px",
                left: "0px",
                backgroundColor: "#000000"
            },
            smviewer: {}
        };
    },
    mounted: function() {
        this.viewer = new Cesium.Viewer("cesiumContainer", {});
        // 隐藏logo
        $(".cesium-widget-credits")[0].style.visibility = "hidden";
        // 隐藏导航工具
        // $(".cesium-viewer-navigationContainer")[0].style.visibility="hidden";

        // 添加OSM地图
        let osm = Cesium.createOpenStreetMapImageryProvider({
            url: "https://tile-a.openstreetmap.fr/hot",
            fileExtension:"png"
        });
        this.viewer.imageryLayers.addImageryProvider(osm);

        var scene = this.viewer.scene;
        var widget = this.viewer.cesiumWidget;
        try {
            // 添加倾斜摄影模型图层
            var promise = scene.addS3MTilesLayerByScp('http://localhost:8090/iserver/services/3D-wz_qidu_qx1/rest/realspace/datas/%E4%B8%83%E9%83%BD_%E5%80%BE%E6%96%9C/config');
            Cesium.when(promise, function(layer) {
                layer.setQueryParameter({
                    url: 'http://localhost:8090/iserver/services/data-wz_qidu_qx1/rest/data',
                    dataSourceName: 'qidu',
                    dataSetName: 'New_Region'
                });
                scene.camera.setView({
                    destination : Cesium.Cartesian3.fromDegrees(120.7630995515332, 28.006422239411936, 100.0),
                    orientation:{
                        heading:160.4816371653797,
                        pitch:-0.515,
                        roll:0
                    }
                });
            }, function() {
                var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
                widget.showErrorPanel(title, undefined, e);
            });
        } catch (e) {
            if (widget._showRenderLoopErrors) {
                var title = '渲染时发生错误,已停止渲染。';
                widget.showErrorPanel(title, undefined, e);
            }
        }

        $("#loadingbar").remove();
    }
};
</script>

<style>

</style>