Documentation / @interstellar-tools/maps / tileAt
Function: tileAt()
ts
function tileAt(phi: Radians, lambda: Radians, zoom: number): TileInterface;Defined in: tiles/tile-at.ts:55
Find the web map tile that holds a point, at a zoom level: the tile scheme web maps use ("slippy maps", XYZ) on the spherical Web Mercator map.
Where:
and are the point's latitude and longitude (rad) is the zoom level: tiles cover the map is the Mercator on a unit sphere (see mercator)
Units
- Inputs: angles in radians,
zooman integer. - Output:
{ x, y, z }, integer tile indices.
Notes
- Columns run east from 180° W, and rows run south from the top edge of the map (see TileInterface).
- The map stops at
, where it is square. Latitudes beyond that, up to the poles, are clamped into the top or bottom row. - The longitude is taken modulo a whole turn, so 180° E is 180° W, the west edge of column 0.
- A point exactly on an edge between tiles belongs to the tile east or south of it.
- The scheme depends only on angles, so it tiles a spherical Mercator map of Mars or the Moon as it does Earth's. A tile is
wide at the equator.
Parameters
| Parameter | Type | Description |
|---|---|---|
phi | Radians | Latitude |
lambda | Radians | Longitude |
zoom | number | Zoom level |
Returns
The tile, { x, y, z }.
Throws
- If
phiorlambdais not a finite number. - If
phiis outside [−π/2, π/2], orzoomis not an integer in [0, 30].
Example
ts
// Oslo, at zoom 10
tileAt(toRad(59.9139), toRad(10.7522), 10); // { x: 542, y: 297, z: 10 }See
- tileBounds
- quadkey
- https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames OpenStreetMap: Slippy map tilenames