# The Mercator Projection

The Map Tile API serves map tiles obtained by mapping points on the surface of a sphere (the globe) to points on a plane, using the *normalized Mercator projection*.

The basic Mercator projection formula is this:

{λ, φ} -> x[-1, 1] y [-1, 1]

In this formula:

λ | = | longitude |

φ | = | latitude |

x | = | λ / π |

y | = | ln(tan(π/4 + φ/2)) / π |

The plane represents the globe as a square grid of map tiles. The size of the grid depends on the map zoom level. At the lowest zoom level, the world is contained in one map tile. At the next higher zoom level, the world is two tiles wide and two tiles high (2x2), at the next level above that, the grid is 4x4, then 8x8, 16x16, and so on up to the maximum zoom for a particular region. In other words, at each zoom level the tiles that make up the complete map of the world form a grid in which the number of tiles is equal to two to the power of two multiplied by the zoom level (2^{(2*zoom)}).

The relationship between tiles at two consecutive zoom levels can be expressed as follows:

col_{1,z+1} = (2*col_{z}) + 1row_{1,z+1} = (2*row_{z}) + 1

In this formula:

col | = | column number in the tile grid |

row | = | row number in the tile grid |

z | = | zoom level |

The diagram below demonstrates this graphically:

```
--- javascript ---
var lat = 52.525439, // Latitude
lon = 13.38727, // Longitude
z = 12, // Zoom level
latRad,
n,
xTile,
yTile;
latRad = lat * Math.PI / 180;
n = Math.pow(2, z);
xTile = n * ((lon + 180) / 360);
yTile = n * (1-(Math.log(Math.tan(latRad) + 1/Math.cos(latRad)) /Math.PI)) / 2;
--- output ---
lat_rad = 0.916
n = 4096
xTile = 2200.31 // Column
yTile = 1343.20 // Row
```

The zoom level and tile row and column can be used as URL variables separated by the '/' character in map tile requests. Note that they must be provided in this order: `zoom/column/row`

. This is the *[Z]/[X]/[Y] addressing scheme*.

The map tile specification is typically preceded by other path variables and may be followed either by further path variables and/or query parameters.