Until now, we only see how to do reprojection using points coordinates but how can we do it for extent?
Head to one of the official examples at http://openlayers.org/en/v3.0.0/examples/wms-image-custom-proj.html?mode=raw and see that you have extent at the layer level typing:
console.log(extent);
Apply a built-in function to transform extent from one coordinate's projection to another one:
ol.proj.transformExtent(extent, 'EPSG:21781', 'EPSG:4326');
We reused the function behind the ol.proj.transform
function without knowledge.
The ol.proj.transformExtent
method expects an extent as a first parameter, as a second parameter, it needs the origin projection, and as a third parameter, it's the destination projection. We declared that we use as input the extent; as origin, EPSG:2181; and as destination, EPSG:4326. At the internal OpenLayers 3 library level, the function loops on the extent and transforms each coordinate.
With this function,...