【类 型】:fix 地图最大化控件 写子类
【原 因】:防止地图 空白 【过 程】:添加一个在点击放大同时 刷新地图 【影 响】:
This commit is contained in:
parent
b3e41420f0
commit
a03cf8b27b
@ -171,7 +171,7 @@ export default {
|
|||||||
// 地图比例
|
// 地图比例
|
||||||
// this.map.addControl(new mapboxgl.ScaleControl(), 'top-right')
|
// 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(
|
// this.map.addControl(
|
||||||
// new mapboxgl.GeolocateControl({
|
// new mapboxgl.GeolocateControl({
|
||||||
@ -561,6 +561,7 @@ export default {
|
|||||||
* @description:重置地图大小
|
* @description:重置地图大小
|
||||||
*/
|
*/
|
||||||
handleResize () {
|
handleResize () {
|
||||||
|
console.log('hi')
|
||||||
if (this.map) {
|
if (this.map) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.map.resize()
|
this.map.resize()
|
||||||
@ -603,6 +604,19 @@ class CustomControl {
|
|||||||
this._map = undefined
|
this._map = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CustomFullscreenControl extends mapboxgl.FullscreenControl {
|
||||||
|
constructor (handleResize) {
|
||||||
|
super()
|
||||||
|
this.handleResize = handleResize
|
||||||
|
}
|
||||||
|
|
||||||
|
_onClickFullscreen () {
|
||||||
|
super._onClickFullscreen() // 调用原始的全屏切换行为
|
||||||
|
this.handleResize() // 调用自定义的 handleResize 方法
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user