Thursday 31 December 2015

javascript - Transform coordinates EPSG:32628 to EPSG:3857 Openlayers 3


I need to transform the example coordinates to a different projection in Openlayers3, the EPSG:32628 to EPSG:3857. I made a function to do it but the result is exactly the same numbers.


function plsHelp(){
var pt = [459123.1209, 3108334.7701];
var scr = new ol.proj.Projection('EPSG:32628');

var dest = new ol.proj.Projection('EPSG:3857');
var test= ol.proj.transform(pt,scr,dest);
console.log(test);
}

What is wrong with the function that is preventing the tranformation of the coordinates from EPSG:32628 to EPSG:3857 in Openlayers 3?



Answer



OpenLayers natively includes the two following projections only: EPSG:3857 and EPSG:4326. To be able to transform to or from any other projections, you must use the Proj4JS library.


Try adding the two following scripts, the first being the Proj4JS library itself, the other the definition of the EPSG:32628 projection:





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...