From 4dab9528d8e69c0c3f8ce03a7d4617bb13ecec8d Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Thu, 31 Mar 2022 14:24:24 +0800
Subject: [PATCH] +注释
---
src/components/map/index.vue | 132 +++++++++++++++++++++++++++++---------------
1 files changed, 87 insertions(+), 45 deletions(-)
diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index 891ef09..5421c65 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -15,23 +15,28 @@
<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;
- "
+ 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 />
+ <dimension
+ :wheelFlag="wheelFlag"
+ :startWheel="startWheel"
+ :startSmallWheel="startSmallWheel"
+ @change-wheel="changeWheel"
+ />
- <!-- <calender /> -->
+ <calender v-if="calenderShow" />
<left-nav ref="leftNav"></left-nav>
@@ -65,12 +70,15 @@
components: {
mapPopup,
campusBuildingSearch,
- dimension
- // calender
+ dimension,
+ calender
},
data () {
return {
- samllMapFlag: false
+ samllMapFlag: false,
+ wheelFlag: true,
+ startWheel: false,
+ startSmallWheel: false
}
},
watch: {
@@ -158,13 +166,12 @@
'campusNavFlag',
'orgNavBarFlag',
'arcNavBarFlag',
- 'searchPopupFlag'
+ 'searchPopupFlag',
+ 'calenderShow'
])
},
mounted () {
var that = this
-
- let eagleViewer
function distanceSurface () {
global.viewer.measure.distanceSurface()
@@ -220,6 +227,11 @@
global.viewer.measure.deactivate()
}
+ if (global.viewer != null) {
+ global.viewer = null
+ global.eagleViewer = null
+ }
+
function initViewer () {
global.viewer = new global.DC.Viewer('viewer-container', {
contextOptions: {
@@ -228,28 +240,29 @@
preserveDrawingBuffer: true
}
}
- }).setOptions({
- // showAtmosphere: false, 大气层
- showMoon: true, // 月亮
- showSun: true, // 太阳
- skyBox: {
- show: true
- }
})
+ // .setOptions({
+ // // showAtmosphere: false, 大气层
+ // showMoon: true, // 月亮
+ // showSun: true, // 太阳
+ // skyBox: {
+ // show: true
+ // }
+ // })
- const chartLayer = new global.DC.ChartLayer('busLayer').addTo(global.viewer)
+ // const chartLayer = new global.DC.ChartLayer('busLayer').addTo(global.viewer)
- chartLayer.setOption(that.busPathsInit())
+ // chartLayer.setOption(that.busPathsInit())
// global.viewer.scene.backgroundColor = global.DC.Namespace.Cesium.Color.fromBytes(245, 244, 238)
- global.viewer.use(new global.DC.Weather())
- global.viewer.weather.cloud.enable = true
- global.viewer.weather.cloud.rotateAmount = 0.02
+ // global.viewer.use(new global.DC.Weather())
+ // global.viewer.weather.cloud.enable = true
+ // global.viewer.weather.cloud.rotateAmount = 0.02
that.$store.commit('SET_VIEWEREXIST', true)
- eagleViewer = new global.DC.Viewer('eagleEyeMap', {
+ global.eagleViewer = new global.DC.Viewer('eagleEyeMap', {
animation: false,
baseLayerPicker: false,
imageryProvider: false,
@@ -266,7 +279,7 @@
// sceneMode: global.DC.Namespace.Cesium.SceneMode.SCENE2D
})
- eagleViewer.imageryLayers.addImageryProvider(
+ global.eagleViewer.imageryLayers.addImageryProvider(
new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
url: 'http://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=9ae78c51a0a28f06444d541148496e36',
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
@@ -276,7 +289,7 @@
})
)
- eagleViewer.imageryLayers.addImageryProvider(
+ global.eagleViewer.imageryLayers.addImageryProvider(
new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
url: 'http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=9ae78c51a0a28f06444d541148496e36',
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
@@ -287,7 +300,7 @@
)
var sceneL = global.viewer.scene
- var sceneR = eagleViewer.scene
+ var sceneR = global.eagleViewer.scene
var handlerL = new global.DC.Namespace.Cesium.ScreenSpaceEventHandler(sceneL.canvas)
var handlerR = new global.DC.Namespace.Cesium.ScreenSpaceEventHandler(sceneR.canvas)
@@ -295,6 +308,30 @@
var isLeftTrigger = false
var isRightTrigger = false
+
+ handlerL.setInputAction(function (movement) {
+ that.startWheel = true
+ if (movement > 0) {
+ // 向下
+ that.wheelFlag = true
+ } else {
+ // 向上
+ that.wheelFlag = false
+ }
+ }, global.DC.Namespace.Cesium.ScreenSpaceEventType.WHEEL)
+
+ handlerR.setInputAction(function (movement) {
+ that.startSmallWheel = true
+ if (that.samllMapFlag) {
+ if (movement > 0) {
+ // 向下
+ that.wheelFlag = true
+ } else {
+ // 向上
+ that.wheelFlag = false
+ }
+ }
+ }, global.DC.Namespace.Cesium.ScreenSpaceEventType.WHEEL)
handlerL.setInputAction(function (movement) {
isLeftTrigger = true
@@ -312,7 +349,7 @@
if (isLeftTrigger) {
const position = global.DC.Transform.transformCartesianToWGS84(global.viewer.camera.position)
- eagleViewer.camera.flyTo({
+ global.eagleViewer.camera.flyTo({
destination: global.DC.Transform.transformWGS84ToCartesian(new global.DC.Position(position.lng, position.lat, position.alt + 1000)),
@@ -338,17 +375,19 @@
var synceagleViewer = function () {
if (isRightTrigger && that.samllMapFlag) {
+ const position = global.DC.Transform.transformCartesianToWGS84(global.eagleViewer.camera.position)
+
global.viewer.camera.flyTo({
- destination: eagleViewer.camera.position,
+ destination: global.DC.Transform.transformWGS84ToCartesian(new global.DC.Position(position.lng, position.lat, position.alt > 1100 ? position.alt - 1000 : 100)),
orientation: {
- heading: eagleViewer.camera.heading,
+ heading: global.eagleViewer.camera.heading,
- pitch: eagleViewer.camera.pitch,
+ pitch: global.eagleViewer.camera.pitch,
- roll: eagleViewer.camera.roll
+ roll: global.eagleViewer.camera.roll
},
@@ -358,11 +397,11 @@
}
}
- eagleViewer.camera.setView({
+ global.eagleViewer.camera.setView({
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
// fromDegrees()方法,将经纬度和高程转换为世界坐标
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
- 115.871863, 28.743861, 1400.0
+ 116.35381525, 27.95839468, 1950.0
),
orientation: {
// 指向
@@ -373,9 +412,9 @@
}
})
- eagleViewer.camera.changed.addEventListener(synceagleViewer)
+ global.eagleViewer.camera.changed.addEventListener(synceagleViewer)
- eagleViewer.scene.preRender.addEventListener(synceagleViewer)
+ global.eagleViewer.scene.preRender.addEventListener(synceagleViewer)
// global.viewer.camera.percentageChanged = 0.01
// eagleViewer.camera.percentageChanged = 0.01
@@ -549,6 +588,9 @@
global.DC.ready(initViewer)
},
methods: {
+ changeWheel (val, type) {
+ this[type] = val
+ },
mapClick (e) {
this.$refs.campusNavRoute.shortcutShow(e)
this.$refs.campusBuildingSearch.shortcutShow(e)
--
Gitblit v1.9.3