Module: ol/proj/proj4

ol/proj/proj4


Functions

epsgLookupMapTiler(key){function}

import {epsgLookupMapTiler} from 'ol/proj/proj4';

Generate an EPSG lookup function which uses the MapTiler Coordinates API to find projection definitions which do not require proj4 to be configured to handle +nadgrids parameters. Call setEPSGLookup use the function for lookups setEPSGLookup(epsgLookupMapTiler('{YOUR_MAPTILER_API_KEY_HERE}')).

Name Type Description
key string

MapTiler API key. Get your own API key at https://www.maptiler.com/cloud/.

Returns:
The EPSG lookup function.

fromEPSGCode(code){Promise<Projection>}

import {fromEPSGCode} from 'ol/proj/proj4';

Get a projection from an EPSG code. This function fetches the projection definition from the epsg.io website, registers this definition for use with proj4, and returns a configured projection. You must call import proj4 and call register before using this function.

If the projection definition is already registered with proj4, it will not be fetched again (so it is ok to call this function multiple times with the same code).

Name Type Description
code number | string

The EPSG code (e.g. 4326 or 'EPSG:4326').

Returns:
The projection.

register(proj4)

import {register} from 'ol/proj/proj4';

Make projections defined in proj4 (with proj4.defs()) available in OpenLayers. Requires proj4 >= 2.8.0.

This function should be called whenever changes are made to the proj4 registry, e.g. after calling proj4.defs(). Existing transforms will not be modified by this function.

Name Type Description
proj4 module:proj4

Proj4.

setEPSGLookup(func)

import {setEPSGLookup} from 'ol/proj/proj4';

Set the lookup function for getting proj4 definitions given an EPSG code. By default, the fromEPSGCode function uses the epsg.io website for proj4 definitions. This can be changed by providing a different lookup function.

Name Type Description
func function

The lookup function.