Reputation: 27
I am trying to convert extent which is in 3857 projection into 26331 projection in OpenLayers by ol.proj.transformExtent(map.getView().calculateExtent(map.getSize()),'EPSG:3857','EPSG:26331')
Upvotes: 0
Views: 385
Reputation: 17907
You will first need to include the proj4js library
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.6.2/proj4.js"></script>
Then the EPSG:26331 proj4js definition from https://epsg.io/26331
proj4.defs("EPSG:26331","+proj=utm +zone=31 +ellps=clrk80 +towgs84=-92,-93,122,0,0,0,0 +units=m +no_defs");
ol.proj.proj4.register(proj4); // if you are using OpenLayers 5 or 6
var transformedExtent = ol.proj.transformExtent(map.getView().calculateExtent(map.getSize()),'EPSG:3857','EPSG:26331');
Upvotes: 1