1

I'm trying to use a program that loads coordinates in EPSG:4326 format and plots on a map. The problem is that my coordinates are in EPSG:3006.

Is there any function to convert one projection in OpenLayers to another EPSG?

  • possible duplicate of [Change Projection in OpenLayers Map](http://stackoverflow.com/questions/2673945/change-projection-in-openlayers-map) – Mochi Mar 21 '14 at 11:16

1 Answers1

1

The better way to do this is to use proj4js library here, it is simple and you can add custom projections if you want.

Below you can see how it works:

var SourceProjection= new Proj4js.Proj('EPSG:4326');
var DestinationProjections= new Proj4js.Proj('EPSG:3006');

var Point = new Proj4js.Point(longitude, latitude);          
Proj4js.transform(FirstProjection, SecondProjections, ne);

Or if you want to do it from openlayers you can use the "transform" function of geometry, here is a custom function that I use:

function TransformGeometry(geometry, SourceProj, DestProj) {
    geometry.transform(
        new OpenLayers.Projection(SourceProj),
        new OpenLayers.Projection(DestProj));

    return geometry;
}

In any case you have to declare proj4js in HTML tag in order to use a "long list" of projections (including here and custom projections you create).