In the documentation of leaflet, it says the following about the projection that is being used:
L.CRS.EPSG3857 The most common CRS for online maps, used by almost
all free and commercial tile providers. Uses Spherical Mercator
projection. Set in by default in Map's crs option.
(emphasis mine)
From this I concluded that I should convert my maps to EPSG:3857 so that this can work in Leaflet. However, this gives very large numbers as coordinates. Which in fact does not work. Turns out that EPSG:3857 is not used in Leaflet. I learned this from here and here. Instead, EPSG:4326 is used.
My question is: what does this part in the documentation mean? I feel like it may need to be changed, but perhaps I don't understand what the map's crs options are…
Best Answer
Leaflet can be a bit confusing for hardcore GIS people, since a
L.CRS
does not represent an abstract CRS. Quoting from the Leaflet docs, it rather...Leaflet does not work with abstract CRSs (as Proj does) - rather, it works with a set of projection and transformation functions that allow to convert
LatLng
coordinates into internal CRS coordinates into screen coordinates and back.In other words: Internally, a
L.CRS
is a set of four functions:project
,unproject
,transform
anduntransform
that do the following:(See Gabriel's answer for more details about each of those three kinds of coordinates)
Therefore,
L.CRS.EPSG3857
is a set of functions that allow forWGS:84→EPSG:3857→screen
andscreen→EPSG:3857→WGS:84
coordinate transforms and not just an abstraction of a CRS.Kinda. EPSG:4326 implies an equirectangular projection, but Leaflet is not using equirectangular projection by default. It just happens to be that spherical coordinates relative to the WGS84 geoid perfectly match equirectangular coordinates for EPSG:4326.
Yes. Leaflet is aimed at web developers first and GISers second. It is very difficult to achieve a perfect balance between a soft learning curve, perfect webdev abstractions, and perfect GIS abstractions (remember that web devs care nada about CRSs, and like to see
LatLng
s and pixels only). The design and documentation can become misleading as a result. Contributions to the docs are always welcome.