# OpenLayers.Projection

Methods for coordinate transforms between coordinate systems. By default, OpenLayers ships with the ability to transform coordinates between geographic (EPSG:4326) and web or spherical mercator (EPSG:900913 et al.) coordinate reference systems. See the transform method for details on usage.

Additional transforms may be added by using the proj4js library. If the proj4js library is included, the transform method will work between any two coordinate reference systems with proj4js definitions.

If the proj4js library is not included, or if you wish to allow transforms between arbitrary coordinate reference systems, use the addTransform method to register a custom transform method.

Summary

OpenLayers.Projection | Methods for coordinate transforms between coordinate systems.
Constructor |
OpenLayers.Projection | This class offers several methods for interacting with a wrapped pro4js projection object.
Functions and Properties |
getCode | Get the string SRS code.
getUnits | Get the units string for the projection -- returns null if proj4js is not available.
defaults | {Object} Defaults for the SRS codes known to OpenLayers (currently EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857, EPSG:102113 and EPSG:102100).
addTransform | Set a custom transform method between two projections.
transform | Transform a point coordinate from one projection to another.
nullTransform |

### Constructor

### OpenLayers.Projection

This class offers several methods for interacting with a wrapped pro4js projection object.

#### Parameters

projCode | {String} A string identifying the Well Known Identifier for the projection.
options | {Object} An optional object to set additional properties on the projection.

#### Returns

{OpenLayers.Projection} A projection object.

### Functions and Properties

### getCode

> getCode: function()

Get the string SRS code.

#### Returns

{String} The SRS code.

### getUnits

> getUnits: function()

Get the units string for the projection -- returns null if proj4js is not available.

#### Returns

{String} The units abbreviation.

### defaults

{Object} Defaults for the SRS codes known to OpenLayers (currently EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857, EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units, maxExtent (the validity extent for the SRS) and yx (true if this SRS is known to have a reverse axis order).

### addTransform

> OpenLayers.Projection.addTransform = function( | from,
> | to,
> | method | )

Set a custom transform method between two projections. Use this method in cases where the proj4js lib is not available or where custom projections need to be handled.

#### Parameters

from | {String} The code for the source projection
to | {String} the code for the destination projection
method | {Function} A function that takes a point as an argument and transforms that point from the source to the destination projection in place. The original point should be modified.

### transform

> OpenLayers.Projection.transform = function( | point,
> | source,
> | dest | )

Transform a point coordinate from one projection to another. Note that the input point is transformed in place.

#### Parameters

point | {OpenLayers.Geometry.Point | Object} An object with x and y properties representing coordinates in those dimensions.
source | {OpenLayers.Projection} Source map coordinate system
dest | {OpenLayers.Projection} Destination map coordinate system

#### Returns

point | {object} A transformed coordinate. The original point is modified.

### nullTransform

> OpenLayers.Projection.nullTransform = function( | point | )

A null transformation | useful for defining projection aliases when proj4js is not available:

>     OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:900913",
>         OpenLayers.Projection.nullTransform);
>     OpenLayers.Projection.addTransform("EPSG:900913", "EPSG:3857",
>         OpenLayers.Projection.nullTransform);

> getCode: function()

Get the string SRS code.

> getUnits: function()

Get the units string for the projection -- returns null if proj4js is not available.

> OpenLayers.Projection.addTransform = function( | from,
> | to,
> | method | )

Set a custom transform method between two projections.

> OpenLayers.Projection.transform = function( | point,
> | source,
> | dest | )

Transform a point coordinate from one projection to another.

> OpenLayers.Projection.nullTransform = function( | point | )

This class offers several methods for interacting with a wrapped pro4js projection object.
Point geometry class.
Close