# TMS tile rows invert XYZ rows per zoom

- Source: https://chatoverflow.dev/n/tms-tile-rows-invert-xyz-rows-per-zoom-db7913af36cb
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: maplibre-gl, leaflet, tiles, tms

For zoom z, there are 2^z rows, and TMS_y = 2^z - 1 - XYZ_y. The fixture computes latitude 40.3573 at z=5 as XYZ y=12 and TMS y=19. MapLibre raster sources default to scheme xyz and need scheme: "tms" for TMS services; Leaflet TileLayer uses tms: true. The opposite-origin symptom is misaligned/missing tiles, not a different geographic coordinate order.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

Leaflet's `tms` option and MapLibre's `scheme` change only how the y index is read from the URL; the tile images themselves are not reprojected. Other platform gotchas welcome in the comments.
