From e733164e1c779b3aef7245936b9daf7875bf791e Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 14 Dec 2023 17:12:33 +0800
Subject: [PATCH] 解决屏幕缩放导致鼠标位置不准确的问题,右侧,切换校区后的显示BUG
---
src/components/map/index.vue | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index 83eddc8..73bdbc9 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -40,7 +40,6 @@
import { Icon, Style, Fill, Text, Stroke, Circle } from 'ol/style.js'
import TilegridTileGrid from "ol/tilegrid/TileGrid"
-
let architecturePolygon = null
let select = null
@@ -174,6 +173,8 @@
this.$refs.leftNav.initialize(newData)
+ this.$refs.campusNavRoute.closeModel()
+
this.createdLayers(newData)
})
}
@@ -214,8 +215,9 @@
mounted () {
const that = this
- this.map2D.setTarget('viewer-container')
this.$nextTick(() => {
+ this.map2D.setTarget('viewer-container')
+
that.map2D.on('pointermove', that.mouseMoveEvent)
this.map2D.on("singleclick", function (event) {
@@ -224,7 +226,7 @@
let flag = true
that.map2D.forEachFeatureAtPixel(
- event.pixel,
+ [event.originalEvent.offsetX, event.originalEvent.offsetY],
(feature) => {
if (flag == false) {
return
@@ -239,6 +241,7 @@
})
})
},
+
methods: {
createdLayers (campusKey) {
const that = this
@@ -302,7 +305,7 @@
select = null
that.map2D.forEachFeatureAtPixel(
- event.pixel,
+ [event.originalEvent.offsetX, event.originalEvent.offsetY],
(feature) => {
if (flag == false) {
return
@@ -360,13 +363,17 @@
if (JSON.stringify(res.data.data) == '{}') return
let result = res.data.data
+ let curLngLat = this.map2D.getCoordinateFromPixel([event.event.originalEvent.offsetX, event.event.originalEvent.offsetY])
+
this.$store.dispatch('setOurDataInPoput', {
- item: result
+ item: result,
+ lng: curLngLat[0],
+ lat: curLngLat[1]
})
this.openPopups({
- lng: Number(event.event.coordinate[0]),
- lat: Number(event.event.coordinate[1]),
+ lng: Number(curLngLat[0]),
+ lat: Number(curLngLat[1]),
item: result,
event
})
@@ -385,7 +392,7 @@
mapClick (e) {
this.$refs.campusNavRoute.shortcutShow(e)
- // this.$refs.campusBuildingSearch.shortcutShow(e)
+ this.$refs.campusBuildingSearch.shortcutShow(e)
},
campusCut (campusKey) {
--
Gitblit v1.9.3