MCPcopy Create free account
hub / github.com/carbonplan/maps / cameraToPoint

Function cameraToPoint

src/utils.js:65–74  ·  view source on GitHub ↗
(x, y, z)

Source from the content-addressed store, hash-verified

63}
64
65export 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
76export const zoomToLevel = (zoom, maxZoom) => {
77 if (maxZoom) return Math.min(Math.max(0, Math.floor(zoom)), maxZoom)

Callers 1

TilesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected