<template>
|
<div id="sdkContainer">
|
<Layer />
|
<div class="positionBtn" v-if="positionBtn.length && !hidePositionBtn">
|
<el-button
|
v-for="item in positionBtn"
|
:key="item.name"
|
type="primary"
|
size="mini"
|
@click="flyToPosition(item)"
|
>{{ item.name }}</el-button
|
>
|
</div>
|
<statusBar ref="statusBar" :show="statusbar" />
|
</div>
|
</template>
|
|
<script>
|
import Layer from './layerTree/Layer';
|
import statusBar from './statusBar';
|
import baseVuex from '@mixin/baseVuex';
|
import Bus from '@tools/Bus';
|
export default {
|
name: 'Viewer',
|
components: {
|
Layer,
|
statusBar,
|
Bus,
|
},
|
mixins: [baseVuex],
|
data() {
|
return {
|
positionBtn: [],
|
};
|
},
|
mounted() {
|
if (window.sceneConfig && sceneConfig.positionBtn) {
|
this.positionBtn = sceneConfig.positionBtn;
|
}
|
this.$nextTick(() => {
|
// 使用单张地图图片
|
window.sgworld = new window.SmartEarth.SGWorld('sdkContainer', {
|
url: window.SmartEarthRootUrl + 'Workers/image/earth.jpg',
|
// 全屏
|
fullscreenButton: true,
|
timeline: true,
|
infoBox: true,
|
mouseDownView: true,
|
licenseServer: window.sceneConfig && sceneConfig.licenseServer,
|
navigationOption: {
|
defaultResetView: this.viewCenter.length
|
? this.viewCenter
|
: [110, 32, 8000000],
|
},
|
});
|
window.Viewer = window.sgworld._Viewer;
|
|
if (this.mapStatus) {
|
for (let status in this.mapStatus) {
|
sgworld[status] = this.mapStatus[status];
|
}
|
}
|
|
Viewer._enableInfoOrSelection = false;
|
//显示fps
|
Viewer.scene.debugShowFramesPerSecond = true;
|
|
// statusBar状态栏
|
this.$refs.statusBar.init();
|
// tooltip提示框
|
window.tooltip = window.sgworld.Core.CreateTooltip();
|
// 等高线工具
|
window.elevationTool = new SmartEarth.ElevationTool(window.sgworld);
|
|
//开启编辑并启用属性弹窗
|
sgworld.Creator.SimpleGraphic.setEdit(true, {
|
editProp: true,
|
editPropData: {
|
offset: 'r',
|
height: '60%',
|
},
|
callBack: {
|
delete: function (entity) {
|
Bus.$emit('removeTreeNode', entity);
|
},
|
end: function (entity) {
|
if (entity) {
|
let style = sgworld.Creator.SimpleGraphic.getStyle(entity);
|
let data = {
|
name: entity.name,
|
style: style,
|
};
|
Bus.$emit('updataTreeNode', entity.id, data);
|
}
|
},
|
},
|
});
|
//军标编辑
|
sgworld.Creator.MilitaryPlotting.setEdit(true, {
|
editProp: true,
|
editPropData: {
|
offset: 'r',
|
height: '60%',
|
success(layero, index) {
|
let contentWindow = layero.find('iframe')[0].contentWindow;
|
let layeroHeight = layero.height();
|
let titleHeight = layero.find('.layui-layer-title').height();
|
let htmlHeight =
|
contentWindow.document.firstElementChild.offsetHeight;
|
if (layeroHeight >= titleHeight + htmlHeight) {
|
layero.height(titleHeight + htmlHeight);
|
}
|
},
|
},
|
callBack: {
|
delete: function (entity) {
|
Bus.$emit('removeTreeNode', entity);
|
},
|
end: function (entity) {
|
if (entity) {
|
let feature = sgworld.Creator.MilitaryPlotting.getFeature(entity);
|
let data = {
|
id: entity.id,
|
name: entity.name,
|
sourceType: 'MilitaryPlotting',
|
feature,
|
};
|
Bus.$emit('updataTreeNode', entity.id, data);
|
}
|
},
|
},
|
});
|
|
if (this.$route.query.hasOwnProperty('gisserver')) {
|
window.isGisserver = true;
|
}
|
// $.ajax({
|
// type: "get",
|
// url: window.location.origin + "/gisserver",
|
// cache: false,
|
// dataType: "jsonp", //跨域采用jsonp方式
|
// processData: false,
|
// timeout: 10000, //超时时间,毫秒
|
// complete: (data) => {
|
// window.isGisserver = data.status == 200;
|
// },
|
// });
|
});
|
},
|
methods: {
|
flyToPosition(data) {
|
let position = data.position;
|
sgworld.Navigate.flyToPosition(position[0], position[1], position[2], {
|
heading: position[3] || 0,
|
pitch: position[4] || -90,
|
roll: position[5] || 0,
|
});
|
if (data.tree) {
|
for (let id in data.tree) {
|
Bus.$emit('checkNode', id, data.tree[id]);
|
}
|
}
|
},
|
},
|
};
|
</script>
|
|
<style scoped lang="less">
|
#sdkContainer {
|
/deep/ .cesium-viewer-fullscreenContainer {
|
display: none !important;
|
}
|
/deep/ .cesium-performanceDisplay-defaultContainer {
|
display: none !important;
|
}
|
|
.positionBtn {
|
position: absolute;
|
top: 0;
|
right: 0;
|
margin: 10px;
|
z-index: 999;
|
}
|
}
|
</style>
|