Class: Projection

ol.proj.Projection

Projection definition class. One of these is created for each projection supported in the application and stored in the ol.proj namespace. You can use these in applications, but this is not required, as API params and options use ol.proj.ProjectionLike which means the simple string code will suffice.

You can use ol.proj.get to retrieve the object for a particular projection.

The library includes definitions for EPSG:4326 and EPSG:3857, together with the following aliases:

  • EPSG:4326: CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84, http://www.opengis.net/gml/srs/epsg.xml#4326, urn:x-ogc:def:crs:EPSG:4326
  • EPSG:3857: EPSG:102100, EPSG:102113, EPSG:900913, urn:ogc:def:crs:EPSG:6.18:3:3857, http://www.opengis.net/gml/srs/epsg.xml#3857

If you use proj4js, aliases can be added using proj4.defs(); see documentation.

new ol.proj.Projection(options)

Name Type Description
options

Projection options.

Name Type Description
code string

The SRS identifier code, e.g. EPSG:4326.

units ol.proj.Units | string

Units.

extent ol.Extent | undefined

The validity extent for the SRS.

axisOrientation string | undefined

The axis orientation as specified in Proj4. The default is enu.

global boolean | undefined

Whether the projection is valid for the whole globe. Default is false.

worldExtent ol.Extent | undefined experimental

The world extent for the SRS.

Methods

getCode(){string}

Get the code for this projection, e.g. 'EPSG:4326'.

Returns:
Code.

Get the validity extent for this projection.

Returns:
Extent.

getMetersPerUnit(){number|undefined}

Get the amount of meters per unit of this projection. If the projection is not configured with a units identifier, the return is undefined.

Returns:
Meters.

Get the units of this projection.

Returns:
Units.

getWorldExtent(){ol.Extent} experimental

Get the world extent for this projection.

Returns:
Extent.

isGlobal(){boolean}

Is this projection a global projection which spans the whole world?

Returns:
Wether the projection is global.

setExtent(extent)

Set the validity extent for this projection.

Name Type Description
extent ol.Extent

Extent.

setWorldExtent(worldExtent) experimental

Set the world extent for this projection.

Name Type Description
worldExtent ol.Extent

World extent [minlon, minlat, maxlon, maxlat].