From ce846cc58fdd88f99d76850918f911787ccd116f Mon Sep 17 00:00:00 2001 From: zengmingjie Date: Thu, 26 Jun 2025 23:32:16 +0800 Subject: [PATCH] 1 --- src/views/contentData/headerTop/index.vue | 29 +++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/views/contentData/headerTop/index.vue b/src/views/contentData/headerTop/index.vue index f7308dd..cf6ddf7 100644 --- a/src/views/contentData/headerTop/index.vue +++ b/src/views/contentData/headerTop/index.vue @@ -70,20 +70,23 @@ export default { watch: { positionPoint: { handler(newVal) { - if (newVal && this.latitude && this.longitude && window.olMap) { - const newLocation = fromLonLat( - [this.longitude, this.latitude], - "EPSG:3857" - ); - this.$message.success("定位成功"); - this.updateMapPosition(this.longitude, this.latitude); - window.olMap.getView().animate({ - center: newLocation, - zoom: 13 - }); + if (newVal) { + if (newVal && this.latitude && this.longitude && window.olMap) { + const newLocation = fromLonLat( + [this.longitude, this.latitude], + "EPSG:3857" + ); + this.$message.success("定位成功"); + this.updateMapPosition(this.longitude, this.latitude); + window.olMap.getView().animate({ + center: newLocation, + zoom: 13 + }); + } + if (this.latitude === "" && this.longitude === "") { + this.$message.error("定位失败,请稍后重试"); + } this.$store.commit("SET_POSITIONPOINT", false); - } else { - this.$message.error("定位失败,请稍后重试"); } }, deep: true