1

I have the following two layers and Open Street Map (OSM) layer. A part of the script is given below. My problem is when I view the results from the browser both the layers fall on a wrong coordinates. I think this is because they are originally ESPG 3006 but the base layer (OSM) is ESPG:3857. Now I want to transform the two layers to match with the base layer ESPG. Can i do this without using any GIS software? Please Help.

vagar_alla = new OpenLayers.Layer.WMS(
                "vagar_alla", "http://localhost:8000/geoserver/myProject/wms",
                {
                    height: '489',
                    width: '512',
                    layers: 'myProject:vagar_alla',
                    styles: '',
                    srs: 'ESPG:3006',
                    format: 'image/png',
                    transparent:true,
                    tiled: 'true',
                    tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
                },
                {
                    buffer: 0,
                    displayOutsideMaxExtent: true

                } 
            );  
adresspt = new OpenLayers.Layer.WMS(
    "adresspt", "http://localhost:8000/geoserver/myProject/wms",
    {
        height: '512',
        width: '458',
        layers: 'myProject:adresspt',
        styles: '',
        srs: 'ESPG:3006',
        format: 'image/png',
        tiled: 'true',
        transparent:true,
        tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom           
    },
    {
        buffer: 0,
        displayOutsideMaxExtent: true
    } 
var osm = new OpenLayers.Layer.OSM();     


    map.addLayers([osm,vagar_alla,adresspt]);
);

1 Answer 1

1

If you remove the line srs: 'ESPG:3006', OpenLayers will request the layer in the projection of the map (in your case epsg:3857) and GeoServer will reproject your layers to that projection before it sends them back (provided that you set the projection of your layers to 3006 correctly).

3
  • Thanks iant for your answer. I commented out the SRS lines but the two layers still fall somewhere else. Any other solution?
    – user19277
    Jul 2, 2013 at 19:33
  • are you sure that they are stored in the correct project in GeoServer? Then check the log file to see if the reprojection is failing
    – Ian Turton
    Jul 3, 2013 at 7:24
  • also try taking out the tilesOrigin line so it's a plain WMS call
    – Ian Turton
    Jul 3, 2013 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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