CRS

Abstract class that defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back (and to coordinates in other units for WMS services). See spatial reference system. Leaflet defines the most usual CRSs by default. If you want to use a CRS not defined by default, take a look at the Proj4Leaflet plugin.

Methods

Method Returns Description
latLngToPoint(<LatLng> latlng, <Number> zoom) Point

Projects geographical coordinates into pixel coordinates for a given zoom.

pointToLatLng(<Point> point, <Number> zoom) LatLng

The inverse of latLngToPoint. Projects pixel coordinates on a given zoom into geographical coordinates.

project(<LatLng> latlng) Point

Projects geographical coordinates into coordinates in units accepted for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).

unproject(<Point> point) LatLng

Given a projected coordinate returns the corresponding LatLng. The inverse of project.

scale(<Number> zoom) Number

Returns the scale used when transforming projected coordinates into pixel coordinates for a particular zoom. For example, it returns 256 * 2^zoom for Mercator-based CRS.

zoom(<Number> scale) Number

Inverse of scale(), returns the zoom level corresponding to a scale factor of scale.

getProjectedBounds(<Number> zoom) Bounds

Returns the projection's bounds scaled and transformed for the provided zoom.

distance(<LatLng> latlng1, <LatLng> latlng2) Number

Returns the distance between two geographical coordinates.

wrapLatLng(<LatLng> latlng) LatLng

Returns a LatLng where lat and lng has been wrapped according to the CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.

Properties

Property Type Description
code String Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857')
wrapLng Number[] An array of two numbers defining whether the longitude (horizontal) coordinate axis wraps around a given range and how. Defaults to [-180, 180] in most geographical CRSs. If undefined, the longitude axis does not wrap around.
wrapLat Number[] Like wrapLng, but for the latitude (vertical) axis.
infinite Boolean If true, the coordinate space will be unbounded (infinite in both axes)

Defined CRSs

CRS Description
L.CRS.EPSG3395 Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
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.
L.CRS.EPSG4326 A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
L.CRS.Earth Serves as the base for CRS that are global such that they cover the earth. Can only be used as the base for other CRS and cannot be used directly, since it does not have a code, projection or transformation. distance() returns meters.
L.CRS.Simple A simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps). Note that the y axis should still be inverted (going from bottom to top). distance() returns simple euclidean distance.
v1.1.0
Props Wrld.Prop
Themes Wrld.themes
Heatmaps Wrld.Heatmap
Events Event objects
Services (Optional) WrldPoiApi