CRS.js

  • Crs()

    Crs's constructor

  • project()

    Projects coordinates using the CRS projection

  • unproject()

    Reverses the projection of a point to its original coordinates

  • latLngToPoint()

    Projects the coordinates using the CRS projection and applies transformation (see transform()) using the zoom level

  • pointToLatLng()

    Reverses the projection of a point to its original coordinates and unstranforms it (see untransform()) using the zoom level

  • transform()

    Transforms the projected point to pixels

  • untransform()

    Pixels are transformed back to projected point

  • scale()

    Returns the associated scale for the given zoom level from the list of scales (calculated as 1 / resolution)

  • resolution()

    Returns the associated resolution for the given zoom level from the list of resolutions

Crs()


constructor

Crs class is used to define the coordinate system of the map

Options:
  • code(String)CRS code (default: 'EPSG:3857')
  • transformation(Transform)CRS transformation (default: new T.Transform(1, 0, -1, 0))
  • resolutions(Array)CRS resolutions
  • maxResolution(Number)CRS max resolution
  • proj(String)CRS projection text. If proj is not defined, code value will be used to create the projection instance
Parameter Type Description
options Object The options of the instance

project()


method

Projects coordinates using the CRS projection

Parameter Type Description
latLng LatLng The coordinates that will be projected
returns
Point - The projected point

unproject()


method

Reverses the projection of a point to its original coordinates

Parameter Type Description
point Point The point that will be unprojected
returns
LatLng - The original coordinates

latLngToPoint()


method

Projects the coordinates using the CRS projection and applies transformation (see transform()) using the zoom level

Parameter Type Description
latLng LatLng The coordinates that will be projected
zoom Number The zoom level for the transformation
returns
Point - The projected point

pointToLatLng()


method

Reverses the projection of a point to its original coordinates and unstranforms it (see untransform()) using the zoom level

Parameter Type Description
point Point The point that will be unprojected
zoom Number The zoom level for the transformation
returns
LatLng - The original coordinates

transform()


method

Transforms the projected point to pixels

Parameter Type Description
point Point The projected point
zoom Number The zoom level that will be scaled (see scale()) for the transformation
returns
Point - The transformed point

untransform()


method

Pixels are transformed back to projected point

Parameter Type Description
point Point The pixel point that will be transformed back
zoom Number The zoom level that will be scaled (see scale()) for the transformation
returns
Point - The untransformed point

scale()


method

Returns the associated scale for the given zoom level from the list of scales (calculated as 1 / resolution)

Parameter Type Description
zoom Number The zoom level
returns
Number - The associated scale value

resolution()


method

Returns the associated resolution for the given zoom level from the list of resolutions

Parameter Type Description
zoom Number The zoom level
returns
Number - The associated resolution