3
var bounds = config.init_center.transform( new OpenLayers.Projection("EPSG:31466"), new OpenLayers.Projection("EPSG:3857"));

    console.log(config.init_center);
    console.log(bounds);

I have coordinates from a map that uses projection epsg:31466 and want to show then on a map with coordinates epsg:3857.

I would expect that the output of the two console logs given above would turn out to be different, since a transformation took place. However, they do NOT differ. They are exactly the same.

What is wrong with my assumption?

  • Have you defined EPSG:31466 somewhere? Openlayers only knows a few definitions, and needs proj4js for the rest. Not as comfortable as real proj4... – AndreJ Oct 28 '14 at 12:31
  • Ah, thank you. What do I need to do in order to get proj4js? – Ferenjito Oct 28 '14 at 12:33
  • Visit proj4js.org. And you have to define the projection 31466. – AndreJ Oct 28 '14 at 12:52
  • Ok, but how do I 'define' the projection 31466? The only thing I have found so far is something like this: Proj4js.defs['EPSG:31466'] = '+proj=tmerc +lat_0=0 +lon_0=6+k=1.000000+x_0=2500000 +y_0=0 +ellps=bessel +units=m +nadgrids=@null +no_defs'; – Ferenjito Oct 28 '14 at 13:08
  • without any explaination. And this site: svn.osgeo.org/metacrs/proj4js/trunk/lib/defs does not contain any information to 31466. – Ferenjito Oct 28 '14 at 13:09
2

Can you try this (change GeoJSON to the format you want to load.):

vector_format = new OpenLayers.Format.GeoJSON({
    'internalProjection': new OpenLayers.Projection("EPSG:31466"),
    'externalProjection': new OpenLayers.Projection("EPSG:3857")
});

result = vector_format.read(newFeatures);
vectorLayer.addFeatures(result);

This worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.