From 2025a212c77d8a9c5261e0ad35ce61c4bad96d2b Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 07 Mar 2022 11:56:40 +0800
Subject: [PATCH] 解决火狐浏览器鹰眼无法正常使用的问题
---
src/components/map/index.vue | 104 ++++++++++++++++++++++++++++-----------------------
1 files changed, 57 insertions(+), 47 deletions(-)
diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index 0712cea..a66db66 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -43,7 +43,12 @@
<org-nav-bar v-if="orgNavBarFlag"></org-nav-bar>
<arc-nav-bar v-if="arcNavBarFlag"></arc-nav-bar>
- <div id="eagleEyeMap" class="eagle-eye-map"></div>
+ <div
+ id="eagleEyeMap"
+ @mouseover="samllMapFlag = true"
+ @mouseleave="samllMapFlag = false"
+ class="eagle-eye-map"
+ ></div>
</div>
</template>
<script>
@@ -62,7 +67,8 @@
data () {
return {
DC: null,
- areaLayer: null
+ areaLayer: null,
+ samllMapFlag: false
}
},
watch: {
@@ -242,37 +248,52 @@
// sceneMode: that.DC.Namespace.Cesium.SceneMode.SCENE2D
})
- eagleViewer.camera.setView({
- // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
- // fromDegrees()方法,将经纬度和高程转换为世界坐标
- destination: that.DC.Namespace.Cesium.Cartesian3.fromDegrees(
- 115.871863, 28.743861, 1400.0
- ),
- orientation: {
- // 指向
- heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
- // 视角
- pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
- roll: 0.0
- }
- })
+ eagleViewer.imageryLayers.addImageryProvider(
+ new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
+ url: ' http://t1.tianditu.gov.cn/vec_w/wmts?tk=9ae78c51a0a28f06444d541148496e36',
+ type: 'wmts',
+ layer: 'vec',
+ style: 'default',
+ format: 'tiles',
+ tileMatrixSetID: 'w',
+ show: true,
+ maximumLevel: 18
+ })
+ )
+ eagleViewer.imageryLayers.addImageryProvider(
+ new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
+ url: ' http://t1.tianditu.gov.cn/cva_w/wmts?tk=9ae78c51a0a28f06444d541148496e36',
+ type: 'wmts',
+ layer: 'cva',
+ style: 'default',
+ format: 'tiles',
+ tileMatrixSetID: 'w',
+ show: true,
+ maximumLevel: 18
+ })
+ )
+
+ var sceneL = viewer.scene
var sceneR = eagleViewer.scene
+ var handlerL = new that.DC.Namespace.Cesium.ScreenSpaceEventHandler(sceneL.canvas)
var handlerR = new that.DC.Namespace.Cesium.ScreenSpaceEventHandler(sceneR.canvas)
var isLeftTrigger = false
var isRightTrigger = false
- viewer.on(that.DC.MouseEventType.MOUSE_MOVE, () => {
+ handlerL.setInputAction(function (movement) {
isLeftTrigger = true
isRightTrigger = false
- })
+ }, that.DC.Namespace.Cesium.ScreenSpaceEventType.MOUSE_MOVE)
handlerR.setInputAction(function (movement) {
- isLeftTrigger = false
- isRightTrigger = true
+ if (that.samllMapFlag) {
+ isLeftTrigger = false
+ isRightTrigger = true
+ }
}, that.DC.Namespace.Cesium.ScreenSpaceEventType.MOUSE_MOVE)
var syncviewer = function () {
@@ -304,7 +325,7 @@
viewer.scene.preRender.addEventListener(syncviewer)
var synceagleViewer = function () {
- if (isRightTrigger) {
+ if (isRightTrigger && that.samllMapFlag) {
viewer.camera.flyTo({
destination: eagleViewer.camera.position,
@@ -324,6 +345,21 @@
})
}
}
+
+ eagleViewer.camera.setView({
+ // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
+ // fromDegrees()方法,将经纬度和高程转换为世界坐标
+ destination: that.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+ 115.871863, 28.743861, 1400.0
+ ),
+ orientation: {
+ // 指向
+ heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
+ // 视角
+ pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
+ roll: 0.0
+ }
+ })
eagleViewer.camera.changed.addEventListener(synceagleViewer)
@@ -355,32 +391,6 @@
// duration: 0.0
// })
// })
-
- eagleViewer.imageryLayers.addImageryProvider(
- new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
- url: ' http://t1.tianditu.gov.cn/vec_w/wmts?tk=9ae78c51a0a28f06444d541148496e36',
- type: 'wmts',
- layer: 'vec',
- style: 'default',
- format: 'tiles',
- tileMatrixSetID: 'w',
- show: true,
- maximumLevel: 18
- })
- )
-
- eagleViewer.imageryLayers.addImageryProvider(
- new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
- url: ' http://t1.tianditu.gov.cn/cva_w/wmts?tk=9ae78c51a0a28f06444d541148496e36',
- type: 'wmts',
- layer: 'cva',
- style: 'default',
- format: 'tiles',
- tileMatrixSetID: 'w',
- show: true,
- maximumLevel: 18
- })
- )
that.createdLayers(viewer)
--
Gitblit v1.9.3