2023-10-03 21:31:40 +08:00
|
|
|
<template>
|
2023-10-24 23:21:38 +08:00
|
|
|
<div style="height: 100%;position: relative;">
|
2023-10-03 21:31:40 +08:00
|
|
|
<div style="height: 100%;" v-loading="loading">
|
|
|
|
<div id="cesiumContainer" style="height: 100%;"></div>
|
|
|
|
</div>
|
2023-10-24 23:21:38 +08:00
|
|
|
<div class="toolbar" style="position: absolute;z-index: 100;bottom: 30px;right:12px;">
|
|
|
|
<el-switch @change="toggleGis"
|
|
|
|
v-model="showGis" active-text="GIS">
|
|
|
|
</el-switch>
|
|
|
|
</div>
|
2023-10-03 21:31:40 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-10-24 23:21:38 +08:00
|
|
|
import { setToken } from '@/utils/auth';
|
|
|
|
|
2023-10-03 21:31:40 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'JhbigscreenMapModle',
|
|
|
|
props: {
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-10-24 23:21:38 +08:00
|
|
|
showGis:true,
|
2023-10-03 21:31:40 +08:00
|
|
|
images: [],
|
|
|
|
loading: false,
|
|
|
|
mapInfo: null,
|
|
|
|
project: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.initMe();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2023-10-24 23:21:38 +08:00
|
|
|
toggleGis(){
|
|
|
|
window.mapApi.Public.setGisState(this.showGis);
|
|
|
|
},
|
2023-10-03 21:31:40 +08:00
|
|
|
initMe() {
|
2023-10-10 22:54:06 +08:00
|
|
|
this.project = this.$root.project||{};
|
2023-10-03 21:31:40 +08:00
|
|
|
this.reloadMap();
|
|
|
|
},
|
|
|
|
reloadMap() {
|
|
|
|
this.mapInfo = {
|
2023-10-24 23:21:38 +08:00
|
|
|
root: "http://szgc.jhncidg.com:808/mapmodel/tools/output/model/202310241728566044/root.glt",
|
|
|
|
modelId: '3a0e7366-ad7b-3dc3-1d86-2331fc1e8578',
|
|
|
|
view:{"heading":4.8798740228358,"pitch":-0.22637630756730465,"position":[1.9366836920898733,0.5884137486301345,31809.670937187617],"headingDegrees":279.59618606401807,"pitchDegrees":-12.970407005361997,"positionWC":{"x":-1909610.0164615875,"y":4984113.66041506,"z":3537723.8441370176}}
|
2023-10-03 21:31:40 +08:00
|
|
|
};
|
|
|
|
this.showMap = true;
|
|
|
|
this.loading = true;
|
|
|
|
setTimeout(this.initMap, 200);
|
|
|
|
|
|
|
|
},
|
2023-10-24 23:21:38 +08:00
|
|
|
setView(){
|
|
|
|
let v=this.mapInfo.view;
|
|
|
|
window.mapApi.Camera.setViewPort(v.position,v.heading,v.pitch);
|
|
|
|
},
|
2023-10-03 21:31:40 +08:00
|
|
|
initMap() {
|
|
|
|
const func = () => {
|
|
|
|
if (!document.getElementById("cesiumContainer")) {
|
|
|
|
setTimeout(func, 50);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!window.initMap) {
|
|
|
|
setTimeout(func, 50);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.loading = false;
|
2023-10-24 23:21:38 +08:00
|
|
|
let v=this.mapInfo.view;
|
2023-10-03 21:31:40 +08:00
|
|
|
window.initMap();
|
2023-10-24 23:21:38 +08:00
|
|
|
let time=+new Date();
|
|
|
|
console.log('%c开始加载模型','color:green')
|
|
|
|
window.mapApi.Model.AddModel(
|
2023-10-03 21:31:40 +08:00
|
|
|
this.mapInfo.root,
|
|
|
|
this.mapInfo.modelId,
|
|
|
|
null,
|
|
|
|
(data) => {
|
2023-10-24 23:21:38 +08:00
|
|
|
window.mapApi.Public.setGisState(true);
|
|
|
|
let ts=(+new Date() - time)/1000;
|
|
|
|
console.log('%c模型加载完成,用时'+ts+'s','color:green')
|
|
|
|
setTimeout(()=>{
|
|
|
|
let v=this.mapInfo.view;
|
|
|
|
window.mapApi.Camera.setViewPort(v.position,v.heading,v.pitch);
|
|
|
|
},400);
|
|
|
|
/*
|
2023-10-03 21:31:40 +08:00
|
|
|
if (Cesium.defined(data)) {
|
2023-10-24 23:21:38 +08:00
|
|
|
setTimeout(()=>{
|
|
|
|
|
|
|
|
},3000)
|
2023-10-03 21:31:40 +08:00
|
|
|
if (Cesium.defined(data.obj) && data.obj instanceof Cesium.Cesium3DTileset) {
|
2023-10-24 23:21:38 +08:00
|
|
|
setTimeout(()=>{
|
|
|
|
let v=this.mapInfo.view;
|
|
|
|
window.mapApi.Camera.setViewPort(v.position,v.heading,v.pitch);
|
|
|
|
},3000);
|
2023-10-03 21:31:40 +08:00
|
|
|
}
|
2023-10-24 23:21:38 +08:00
|
|
|
}*/
|
2023-10-03 21:31:40 +08:00
|
|
|
$("#box,#LoadingShadow").hide()
|
2023-10-24 23:21:38 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
});
|
2023-10-03 21:31:40 +08:00
|
|
|
window.mapApi.Public.Event("LEFT_CLICK", function (click) {
|
|
|
|
window.mapApi.Feature.GetFeatureByEvent(click.position, function (json) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
func();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less">
|
|
|
|
#cesiumContainer {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
2023-10-24 23:21:38 +08:00
|
|
|
.cesium-viewer-toolbar{
|
|
|
|
display: none !important;
|
|
|
|
}
|
2023-10-03 21:31:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#cesium-plugin-cube_cesiumContainer {
|
|
|
|
transform: scale(0.6);
|
2023-10-24 23:21:38 +08:00
|
|
|
|
2023-10-03 21:31:40 +08:00
|
|
|
}
|
|
|
|
</style>
|