From 3ba7b2bfabfa9cdced5938c80509d12c018fadfa Mon Sep 17 00:00:00 2001 From: Franzz Date: Wed, 20 May 2026 17:16:17 +0200 Subject: [PATCH] Fix initial world size on mobile --- src/components/project.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/project.vue b/src/components/project.vue index b771f61..27cd1ae 100644 --- a/src/components/project.vue +++ b/src/components/project.vue @@ -233,9 +233,12 @@ export default { //Adapt zoom to see whole planet const $Canvas = this.map.getCanvas(); - const iTargetRadius = Math.min($Canvas.clientWidth, $Canvas.clientHeight) / 2; - const iWorldSize = iTargetRadius * 2 * Math.PI * Math.cos(oDefaultProject.latitude * Math.PI / 180); + const oMapBounds = this.map.getContainer().getBoundingClientRect(); + //Adapt zoom to see whole planet + const iTargetRadius = Math.max(1, Math.min(oMapBounds.width || $Canvas.clientWidth, oMapBounds.height || $Canvas.clientHeight) / 2); + const iWorldSize = iTargetRadius * 2 * Math.PI * Math.cos(oDefaultProject.latitude * Math.PI / 180); + this.map.jumpTo({ center: new LngLat(oDefaultProject.longitude, oDefaultProject.latitude), zoom: Math.log2(iWorldSize / this.map.transform.tileSize)