Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to discuss a scenario here to all.

  1. I have developed a Web mapping application in OpenLayers and GeoServer. The customer give us shapefiles with native projection SWREFF99_1330 (EPSG:3008). i published this shapefile on Geoserver after changing its native projection from EPSG:3008 to EPSG:4326 by using ogr2ogr tool. The layer displayed perfectly over Google map layer in my OpenLayers Web Page.

  2. Again, I publish this shapefile on GeoServer with its native projection (this time, without changing projection using ogr2ogr tool) and then i go to my page and figure out that the layer was not visible over Google map layer.

Now, my question to all members:

Is there any way to change the native projection from EPSG:3008 to EPSG:4326 at client side (in my OpenLayers web page code) ? so that the layer should display correctly over google base layer as in case 1.

share|improve this question
    
The projection can also be done by GeoServer. –  Sean Aug 11 '11 at 14:40

1 Answer 1

You can project in Openlayers like this:

    var map = new OpenLayers.Map("map", {
  projection: new OpenLayers.Projection("EPSG:3008"),
  displayProjection: new OpenLayers.Projection("EPSG:4326")
}); 

Proj4js is required to do this on the client side.

share|improve this answer
    
doesn't OL come bundled with proj4js? –  ilia choly Aug 11 '11 at 14:36
    
    
OpenLayers integrates with Proj4js if the library is available > trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js –  Mapperz Aug 11 '11 at 15:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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