(x, y, z)
| 63 | } |
| 64 | |
| 65 | export const cameraToPoint = (x, y, z) => { |
| 66 | const z2 = Math.pow(2, z) |
| 67 | |
| 68 | const lon = 360 * (x / z2) - 180 |
| 69 | |
| 70 | const y2 = 180 - (y / z2) * 360 |
| 71 | const lat = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90 |
| 72 | |
| 73 | return [lon, lat] |
| 74 | } |
| 75 | |
| 76 | export const zoomToLevel = (zoom, maxZoom) => { |
| 77 | if (maxZoom) return Math.min(Math.max(0, Math.floor(zoom)), maxZoom) |