Fix initial world size on mobile
All checks were successful
Deploy Spot / deploy (push) Successful in 38s

This commit is contained in:
2026-05-20 17:16:17 +02:00
parent b44d2960f7
commit 3ba7b2bfab

View File

@@ -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)