[OpenLayers-Users] problem with setting projections

kuba rojekk at gmail.com
Fri Nov 21 13:41:45 EST 2008


Hi!!

  I would like to display my shp data in other Projection than "EPSG: 
4326"(WGS 84). Basically i am interested to show it in following  
projections "EPSG:3395"(World Mercator) or "EPSG:3395"(Google  
Mercator). I have set up Geoserver where i store two copies of the  
same polygons(one in "EPSG:3395"(World Mercator) projection and  
second  in default "EPSG:4326"(WGS 84) ).  When i look at the data in  
preview they are correctly projected.I have tried to show both using  
OpenLayers, but i could have managed to do that for "EPSG:4326"(WGS  
84). When i only try to change the projection of  the map or layer for  
EPSG:3395"(World Mercator, than nothing can be seen. There is no bug  
or any Error. I have check it with firebug.

This code allows me to generate the map but the projection of  
displayed map is on the one that i want to have. it is Always  
WGS84(EPSG:4326") and it does not matter what kind projection have the  
data stored on Geoserver.


Shp in world mercator projection
map = new OpenLayers.Map( 'map' );
layer = new OpenLayers.Layer.WMS( "Europ", "http://localhost:8080/geoserver/wms? 
", {layers: 'unemployment:ue2000_WorldMercator'} )

Shp in WGS84
map = new OpenLayers.Map( 'map' );
layer = new OpenLayers.Layer.WMS( "Europ", "http://localhost:8080/geoserver/wms? 
", {layers: 'unemployment:ue2000_wgs84'} )




I thought that this might work but i does not ... and i do not know  
why??

   map = new OpenLayers.Map( 'map', {projection:"EPSG:3395"} );
  layer = new OpenLayers.Layer.WMS( "Europ", "http://localhost:8080/geoserver/wms? 
", {layers: 'unemployment:ue2000_wgs84'} );


map = new OpenLayers.Map( 'map' );
layer = new OpenLayers.Layer.WMS( "Europ", "http://localhost:8080/geoserver/wms? 
", {layers: 'unemployment:ue2000_wgs84'}, { maxExtent: new  
OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution:  
"auto", projection:"EPSG:3395", units: "m"} );

   map = new OpenLayers.Map( 'map', {projection:"EPSG:3395"} );
  layer = new OpenLayers.Layer.WMS( "Europ", "http://localhost:8080/geoserver/wms? 
", {layers: 'unemployment:ue2000_Project_WorldMercator'} );


map = new OpenLayers.Map( 'map' );
layer = new OpenLayers.Layer.WMS( "Europ", "http://localhost:8080/geoserver/wms? 
", {layers: 'unemployment:ue2000_Project_WorldMercator'}, { maxExtent:  
new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution:  
"auto", projection:"EPSG:3395", units: "m"} );

Please help me !!!!!

  Kuba 



More information about the Users mailing list