From a03cf8b27b8cf887bc7b2277558e3371fd0975aa Mon Sep 17 00:00:00 2001 From: tk Date: Thu, 25 Jul 2024 13:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afix=20=E5=9C=B0=E5=9B=BE=E6=9C=80=E5=A4=A7=E5=8C=96?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=20=E5=86=99=E5=AD=90=E7=B1=BB=20=E3=80=90?= =?UTF-8?q?=E5=8E=9F=20=20=E5=9B=A0=E3=80=91=EF=BC=9A=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=20=E7=A9=BA=E7=99=BD=20=E3=80=90=E8=BF=87=20?= =?UTF-8?q?=20=E7=A8=8B=E3=80=91=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=9C=A8=E7=82=B9=E5=87=BB=E6=94=BE=E5=A4=A7=E5=90=8C?= =?UTF-8?q?=E6=97=B6=20=20=E5=88=B7=E6=96=B0=E5=9C=B0=E5=9B=BE=20=E3=80=90?= =?UTF-8?q?=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MapBox.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/MapBox.vue b/src/components/MapBox.vue index 4728f7d..d389de1 100644 --- a/src/components/MapBox.vue +++ b/src/components/MapBox.vue @@ -171,7 +171,7 @@ export default { // 地图比例 // this.map.addControl(new mapboxgl.ScaleControl(), 'top-right') // 全屏 - this.map.addControl(new mapboxgl.FullscreenControl(), 'top-right') + this.map.addControl(new CustomFullscreenControl(this.handleResize), 'top-right') // 跟随飞机 // this.map.addControl( // new mapboxgl.GeolocateControl({ @@ -561,6 +561,7 @@ export default { * @description:重置地图大小 */ handleResize () { + console.log('hi') if (this.map) { setTimeout(() => { this.map.resize() @@ -603,6 +604,19 @@ class CustomControl { this._map = undefined } } + +class CustomFullscreenControl extends mapboxgl.FullscreenControl { + constructor (handleResize) { + super() + this.handleResize = handleResize + } + + _onClickFullscreen () { + super._onClickFullscreen() // 调用原始的全屏切换行为 + this.handleResize() // 调用自定义的 handleResize 方法 + } +} +