From 88262ad14e9645095af9021192a9625a7169849b Mon Sep 17 00:00:00 2001 From: Manuel Kasper Date: Fri, 18 Jun 2021 20:57:03 +0200 Subject: [PATCH] Improve map performance by leaving preserveDrawingBuffer set to false (and still making map downloads work by applying the trick from https://github.com/mapbox/mapbox-gl-js/issues/2766#issuecomment-370758650) --- src/components/MapDownloadControl.vue | 15 +++++++++------ src/views/Map.vue | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/MapDownloadControl.vue b/src/components/MapDownloadControl.vue index 5c64e71..f8c4f67 100644 --- a/src/components/MapDownloadControl.vue +++ b/src/components/MapDownloadControl.vue @@ -10,12 +10,15 @@ export default { inject: ['map'], methods: { downloadMap () { - let link = document.createElement('a') - link.download = 'map.png' - link.href = this.map.getCanvas().toDataURL() - document.body.appendChild(link) - link.click() - document.body.removeChild(link) + this.map.once('render', () => { + let link = document.createElement('a') + link.download = 'map.png' + link.href = this.map.getCanvas().toDataURL() + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + }) + this.map._render() } } } diff --git a/src/views/Map.vue b/src/views/Map.vue index 97e6d40..7ea2415 100644 --- a/src/views/Map.vue +++ b/src/views/Map.vue @@ -1,6 +1,6 @@