(bounds, mapContainerStyle, tileSize = 512, worldWidth = WORLD_WIDTH)
| 705 | } |
| 706 | |
| 707 | _getResizedZoom(bounds, mapContainerStyle, tileSize = 512, worldWidth = WORLD_WIDTH) { |
| 708 | const { width, height } = mapContainerStyle; |
| 709 | const lngArcLength = Math.abs(bounds.getEast() - bounds.getWest()); |
| 710 | const latArcLength = Math.abs( |
| 711 | this._getBoundsRadian(bounds.getSouth()) - this._getBoundsRadian(bounds.getNorth()) |
| 712 | ); |
| 713 | const lngResizeZoom = +Math.log2(worldWidth / ((lngArcLength / parseInt(width)) * tileSize)).toFixed(2); |
| 714 | const latResizeZoom = +Math.log2(worldWidth / ((latArcLength / parseInt(height)) * tileSize)).toFixed(2); |
| 715 | if (lngResizeZoom <= latResizeZoom) { |
| 716 | return lngResizeZoom; |
| 717 | } |
| 718 | return latResizeZoom; |
| 719 | } |
| 720 | |
| 721 | _getBoundsRadian(point) { |
| 722 | return (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (point * Math.PI) / 360)); |
no test coverage detected