How leaflet does to calculate the x y coordinates of the tiles from zoom z, latitude and longitude coordinates ? what is the formula please?
Thank you
In case you are referring to computation of tile z x y "coordinates" / names, then there is a very simple algorithm, as described on OpenStreetMap wiki about slippy maps: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
Lon./lat. to tile numbers
n = 2 ^ zoom
xtile = n * ((lon_deg + 180) / 360)
ytile = n * (1 - arsinh(tan(lat_rad)) / π)) / 2
With arsinh being the Inverse hyperbolic sine
Some background explanation:
X goes from 0 (left edge is 180 °W) to 2zoom − 1 (right edge is 180 °E)
Y goes from 0 (top edge is 85.0511 °N) to 2zoom − 1 (bottom edge is 85.0511 °S) in a Mercator projection
See the wiki page for further explanation and details, as well as some code in different programming languages.
L.GridLayer
's_update
, thenL.Map
'sproject, then
L.CRS's
latLngToPoint, then
L.Projection.SphericalMercator's
project`. But I think that you are not really interested in how Leaflet does this, but in how to calculate this yoruself, so you should start by reading wiki.openstreetmap.org/wiki/Slippy_map_tilenames instead. – IvanSanchez