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)