【类 型】:fix 地图最大化控件 写子类

【原  因】:防止地图 空白
【过  程】:添加一个在点击放大同时  刷新地图
【影  响】:
This commit is contained in:
tk 2024-07-25 13:15:08 +08:00
parent b3e41420f0
commit a03cf8b27b

View File

@ -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
}
}
</script>
<style lang="scss" scoped>