user1919
user1919

Reputation: 3938

Transformation between projections doesn't work

I am trying to make a transformation between two different projections using openlayers but I can not make it work. I am sure that my source projection is EPSG:2100 and I need to transform it to my maps Projection which is the Spherical Mercator.

What ever I do the marker I create and place on the map is always on the same position:

       var addMarker = function(){

           var fromProjection = new OpenLayers.Projection("EPSG:2100");
           var toProjection   = new OpenLayers.Projection("EPSG:4326"); 
           var position       = new OpenLayers.LonLat(479758.284700697,4207092.83410554).transform( fromProjection, toProjection);

           markers = new OpenLayers.Layer.Markers("Markers");
           map.addLayer(markers);

           marker = new OpenLayers.Marker(position)
          markers.addMarker(marker); 
         };
          var destroyMarker = function(){
           markers.removeMarker(marker);

       };

Upvotes: 0

Views: 489

Answers (1)

Genti Qirjazi
Genti Qirjazi

Reputation: 101

I think that you have to declare your projection first (EPSG:2100). You can use proj4js Library to do that.

I tried your code and this is what it shown to me:`

"NetworkError: 404 Not Found - http://localhost:19614/JSLib/proj4js/lib/defs/EPSG2100.js"

This happens when your projection is not known from your Library.

And something else: EPSG:4326 is not Spherical Mercator it is the code for WGS84. For Sperical Mercator you have to use: EPSG:900913 or EPSG:3857. For more information about EPSG Datasets you can look here

Upvotes: 2

Related Questions