MCPcopy
hub / github.com/google-map-react/google-map-react / latLng2World

Function latLng2World

src/lib/index.js:5–16  ·  view source on GitHub ↗
({ lat, lng })

Source from the content-addressed store, hash-verified

3const GOOGLE_TILE_SIZE = 256;
4
5function latLng2World({ lat, lng }) {
6 const sin = Math.sin((lat * Math.PI) / 180);
7 const x = lng / 360 + 0.5;
8 let y = 0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI;
9
10 y = y < 0 // eslint-disable-line
11 ? 0
12 : y > 1
13 ? 1
14 : y;
15 return { x, y };
16}
17
18function world2LatLng({ x, y }) {
19 const n = Math.PI - 2 * Math.PI * y;

Callers 3

meters2WorldSizeFunction · 0.85
fitNwSeFunction · 0.85
latLng2TileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected