Documentation / @interstellar-tools/maps / tileBounds
Function: tileBounds()
ts
function tileBounds(x: number, y: number, z: number): TileBoundsInterface;Defined in: tiles/tile-bounds.ts:48
Find the edges of a web map tile: the latitudes of its north and south edges and the longitudes of its west and east edges. The inverse of tileAt.
Where:
and are the tile's column and row; and give its east and south edges is the zoom level
Units
- Inputs: integer tile indices.
- Output:
{ north, south, west, east }in radians.
Notes
- Neighbouring tiles share their edges exactly: the east edge of one tile is the west edge of the next.
- The top row's north edge, and the bottom row's south edge, are the map's limit,
. - Tiles are square on the map, but on the sphere they are as wide as they are tall only near the equator.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | Column, east from 180° W (an integer in [0, 2^z)). |
y | number | Row, south from the top edge of the map (an integer in [0, 2^z)). |
z | number | Zoom level (an integer in [0, 30]). |
Returns
The tile's edges, { north, south, west, east } in radians.
Throws
If z is not an integer in [0, 30], or x or y is not an integer in [0, 2^z).
Example
ts
// The single tile at zoom 0 is the whole map
tileBounds(0, 0, 0);
// { north: 85.0511°, south: −85.0511°, west: −180°, east: 180° }, in radiansSee
- tileAt
- https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames OpenStreetMap: Slippy map tilenames