/* eslint-disable camelcase */
|
<template>
|
<div
|
id="viewer-container"
|
style="height: 100%; width: 100%"
|
@click="mapClick($event)"
|
>
|
<video
|
id="video"
|
style="position: fixed; visibility: hidden"
|
muted
|
autoplay
|
loop
|
crossorigin
|
controls
|
>
|
<source
|
src="http://dc.dvgis.cn/examples/data/demo.mp4"
|
type="video/mp4"
|
/>
|
</video>
|
|
<div
|
style="
|
position: fixed;
|
left: 4px;
|
bottom: 4px;
|
width: 80px;
|
line-height: 24px;
|
text-align: center;
|
color: #fff;
|
font-size: 14px;
|
border-radius: 4px;
|
background: #2196f3ed;
|
z-index: 11;
|
"
|
>
|
智慧校区
|
</div>
|
|
<dimension :areaLayer="areaLayer" />
|
|
<left-nav ref="leftNav"></left-nav>
|
|
<mapPopup />
|
|
<campusBuildingSearch ref="campusBuildingSearch" />
|
|
<campusNav ref="campusNavRoute" v-show="campusNavFlag" />
|
|
<search-details v-if="searchPopupFlag"></search-details>
|
<org-nav-bar v-if="orgNavBarFlag"></org-nav-bar>
|
<arc-nav-bar v-if="arcNavBarFlag"></arc-nav-bar>
|
</div>
|
</template>
|
<script>
|
import { mapGetters } from "vuex";
|
import mapPopup from "./components/mapPopup.vue";
|
import campusBuildingSearch from "./components/campusBuildingSearch.vue";
|
import dimension from "./components/dimension.vue";
|
|
export default {
|
name: "mapBox",
|
components: {
|
mapPopup,
|
campusBuildingSearch,
|
dimension,
|
},
|
data() {
|
return {
|
DC: null,
|
areaLayer: null,
|
};
|
},
|
watch: {
|
searchPopupFlag: {
|
immediate: true,
|
handler(newVal, oldVal) {
|
if (newVal == true) {
|
if (this.$route.path.indexOf("/pcLayout/default/service") != -1) {
|
this.$store.dispatch("delVisitedViews", this.$route);
|
this.$router.push("/pcLayout/default");
|
}
|
|
if (this.$route.path.indexOf("/orgnav") != -1) {
|
this.$store.dispatch("delVisitedViews", this.$route);
|
this.$router.push("/pcLayout/default");
|
this.$store.commit("SET_ORGNAVBARTITLE", "");
|
this.$store.commit("SET_ORGNAVBARLIST", []);
|
this.$store.commit("SET_ORGNAVBARFLAG", false);
|
}
|
|
if (this.orgNavBarFlag == true) {
|
this.$store.commit("SET_ORGNAVBARTITLE", "");
|
this.$store.commit("SET_ORGNAVBARLIST", []);
|
this.$store.commit("SET_ORGNAVBARFLAG", false);
|
}
|
|
if (this.$route.path.indexOf("/arc") != -1) {
|
this.$store.dispatch("delVisitedViews", this.$route);
|
this.$router.push("/pcLayout/default");
|
this.$store.commit("SET_ARCNAVBARTITLE", "");
|
this.$store.commit("SET_ARCNAVBARCODE", "");
|
this.$store.commit("SET_ARCNAVBARFLAG", false);
|
}
|
|
if (this.arcNavBarFlag == true) {
|
this.$store.commit("SET_ARCNAVBARTITLE", "");
|
this.$store.commit("SET_ARCNAVBARCODE", "");
|
this.$store.commit("SET_ARCNAVBARFLAG", false);
|
}
|
}
|
},
|
},
|
|
orgNavBarFlag: {
|
immediate: true,
|
handler(newVal, oldVal) {
|
if (newVal == true) {
|
this.$store.commit("SET_SEARCHPOPUPFLAG", false);
|
}
|
},
|
},
|
|
arcNavBarFlag: {
|
immediate: true,
|
handler(newVal, oldVal) {
|
if (newVal == true) {
|
this.$store.commit("SET_SEARCHPOPUPFLAG", false);
|
}
|
},
|
},
|
},
|
computed: {
|
...mapGetters([
|
"viewer",
|
"popupBgUrl",
|
"pupupQRUrl",
|
// 终点
|
"terminus",
|
// 起点
|
"startingPoint",
|
// 点信息
|
"pointPosition",
|
// 点名称
|
"stateName",
|
// 地址
|
"siteName",
|
// 介绍
|
"introduceText",
|
// 全景地址
|
"panoramaUrl",
|
// 详情弹框显示关闭
|
"detailsPopup",
|
// 全景弹框显示关闭
|
"panoramaPopup",
|
// 校区内导航的显示关闭
|
"campusNavFlag",
|
"orgNavBarFlag",
|
"arcNavBarFlag",
|
"searchPopupFlag",
|
]),
|
},
|
mounted() {
|
var that = this;
|
|
let viewer;
|
|
that.DC = global.DC;
|
|
function distanceSurface() {
|
viewer.measure.distanceSurface();
|
}
|
|
function calcArea() {
|
viewer.measure.area();
|
}
|
|
function areaSurface() {
|
viewer.measure.areaSurface();
|
}
|
|
function calcAngle() {
|
viewer.measure.angle();
|
}
|
|
function calcModelAngle() {
|
viewer.measure.angle({
|
clampToModel: true,
|
});
|
}
|
|
function calcHeight() {
|
viewer.measure.height();
|
}
|
|
function calcModelHeight() {
|
viewer.measure.height({
|
clampToModel: true,
|
});
|
}
|
|
function calcHeading() {
|
viewer.measure.heading();
|
}
|
|
function areaHeight() {
|
viewer.measure.areaHeight();
|
}
|
|
function calcTriangleHeight() {
|
viewer.measure.triangleHeight();
|
}
|
|
function calcModelTriangleHeight() {
|
viewer.measure.triangleHeight({
|
clampToModel: true,
|
});
|
}
|
|
function deactivate() {
|
viewer.measure.deactivate();
|
}
|
|
function initViewer() {
|
viewer = new that.DC.Viewer("viewer-container", {
|
contextOptions: {
|
webgl: {
|
stencil: true,
|
preserveDrawingBuffer: true,
|
},
|
},
|
});
|
|
that.createdLayers(viewer);
|
|
that.$store.commit("SET_VIEWER", viewer);
|
|
that.$refs.leftNav.initialize(viewer);
|
|
// const key = '0f7c1d161d7352116a21aacf0e9f44c1'
|
// const vec = that.DC.ImageryLayerFactory.createTdtImageryLayer({
|
// key
|
// })
|
// const cva = that.DC.ImageryLayerFactory.createTdtImageryLayer({
|
// key,
|
// style: 'cva'
|
// })
|
// viewer.addBaseLayer([vec, cva])
|
|
// const areaLayer = new that.DC.VectorLayer('areaLayer')
|
|
// viewer.addLayer(areaLayer)
|
|
// axios.get('http://59.55.128.156:6080/arcgis/rest/services/xiajiangfhgc/MapServer/4/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&returnTrueCurves=false&resultOffset=&resultRecordCount=&f=pjson').then(resultData => {
|
// resultData.data.features.forEach(item => {
|
// item.geometry.rings[0].forEach(it => {
|
// it = it.join(',')
|
// })
|
|
// item.geometry.rings[0] = item.geometry.rings[0].join(';')
|
|
// const polygon = new that.DC.Polygon(item.geometry.rings[0])
|
|
// polygon.setStyle({
|
|
// material: that.DC.Namespace.Cesium.Color.fromBytes(255, 255, 255, 0)
|
|
// })
|
|
// areaLayer.addOverlay(polygon)
|
// })
|
// })
|
|
// var select = {
|
// overlay: undefined,
|
// color: undefined
|
// }
|
|
// viewer.on(that.DC.MouseEventType.MOUSE_MOVE, e => {
|
// if (e.overlay != undefined) {
|
// if (select.overlay != undefined) {
|
// if (e.overlay != select.overlay) {
|
// select.overlay.setStyle({
|
// material: select.color
|
// })
|
|
// select.overlay = undefined
|
// select.color = undefined
|
// }
|
// }
|
|
// if (select.overlay == undefined) {
|
// select.overlay = e.overlay
|
|
// select.color = e.overlay._style.material
|
// select.overlay.setStyle({
|
|
// material: that.DC.Namespace.Cesium.Color.fromBytes(32, 108, 247, 158)
|
|
// })
|
// }
|
// } else {
|
// if (select.overlay != undefined) {
|
// select.overlay.setStyle({
|
// material: select.color
|
// })
|
|
// select.overlay = undefined
|
// select.color = undefined
|
// }
|
// }
|
// })
|
|
// viewer.on(that.DC.MouseEventType.CLICK, e => {
|
// if (e.overlay != undefined) {
|
// console.log(e.overlay.attr)
|
// }
|
// })
|
|
// viewer.addBaseLayer(baselayer, {
|
// iconUrl: 'examples/images/icon/img.png',
|
// name: '影像'
|
// })
|
|
// viewer.addBaseLayer(wmtslayer, {
|
// iconUrl: 'examples/images/icon/img.png',
|
// name: '影像'
|
// })
|
|
// // eslint-disable-next-line camelcase
|
// const baselayer_shaded = that.DC.ImageryLayerFactory.createArcGisImageryLayer({
|
// url:
|
// 'http://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer'
|
// })
|
// viewer.addBaseLayer(baselayer_shaded, {
|
// iconUrl: 'examples/images/icon/elec.png',
|
// name: '电子'
|
// })
|
|
// // eslint-disable-next-line camelcase
|
// const baselayer_street = that.DC.ImageryLayerFactory.createArcGisImageryLayer({
|
// url:
|
// 'http://services.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer'
|
// })
|
// viewer.addBaseLayer(baselayer_street, {
|
// iconUrl: 'examples/images/icon/ter.png',
|
// name: '地形'
|
// })
|
|
// // eslint-disable-next-line camelcase
|
// const baselayer_ter = that.DC.ImageryLayerFactory.createArcGisImageryLayer({
|
// url:
|
// 'http://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer'
|
// })
|
// viewer.addBaseLayer(baselayer_ter, {
|
// iconUrl: 'examples/images/icon/ter.png',
|
// name: '地形'
|
// })
|
|
viewer.use(new that.DC.Measure());
|
|
// viewer.flyToPosition(
|
// new that.DC.Position(117.08489820, 31.65413916, 1500, 0, -90, 45)
|
// )
|
|
viewer.compass.enable = true;
|
viewer.zoomController.enable = true;
|
viewer.locationBar.enable = true;
|
viewer.hawkeyeMap.enable = true;
|
viewer.hawkeyeMap.addBaseLayer(
|
that.DC.ImageryLayerFactory.createAmapImageryLayer({
|
crs: "WGS84",
|
})
|
);
|
// viewer.distanceLegend.enable = true
|
}
|
|
that.DC.ready(initViewer);
|
},
|
methods: {
|
mapClick(e) {
|
this.$refs.campusNavRoute.shortcutShow(e);
|
this.$refs.campusBuildingSearch.shortcutShow(e);
|
},
|
|
createdLayers(viewer) {
|
const layerGroup = new this.DC.LayerGroup("modelBox");
|
viewer.addLayerGroup(layerGroup);
|
|
this.areaLayer = new this.DC.VectorLayer("areaLayer");
|
layerGroup.addLayer(this.areaLayer);
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scope></style>
|