Working with projections
As we've learned in previous recipes in this book, OpenLayers has built-in support for the EPSG:4326
and EPSG:3857
projections. Of course, this is very useful, but it is also rather limited when you need to work with other projections worldwide. Offering more built-in projections would add bloat to the library, and transforming between projections is not a simple task.
Instead, OpenLayers outsources this task to other libraries dedicated to transforming projections from one to another. One such library is called Proj4js (http://proj4js.org), which OpenLayers integrates with seamlessly.
So, when we want to work with projections other than EPSG:4326
and EPSG:3857
, we look to the help of Proj4js.
Note
Teaching you about projections is outside the scope of this book. The EPSG codes are simply a standardized way to classify and identify a great amount of available projections. EPSG:4326
corresponds to the World Geodetic System (WGS84), and EPSG:3857
is the Spherical Mercator...