2
votes

I want to add a wms-overlay to an existing openlayers-map on a website. The layer is stored on geoserver. When i open the layer on geoserver, it works just fine. The data itself is in EPSG:31297.

But when i load the website openlayers is empty. Although the layer is shown in the layerswitcher.

I know there are a few questions concerning that topic, usually it had something to do with the project. However, in this case the projection should be fine. I can't figure out why it doesn't work.

Here is the code:

// My layer 
        var wms_layer = new OpenLayers.Layer.WMS (
            "Layer",
            "http://.../geoserver/wms",
            {
                layers: "master:dauersied_2mio",                
                transparent: "true",
                projection: "EPSG:3857"

            },
            {isBaseLayer: false}
        );  

        map.addLayer(wms_layer);
1
Have you checked the images coming back from Geoserver in network tab of dev tools (in whatever browser you are using) to make sure it looks right. Is you Geoserver dataset vector or raster based? Because, obviously, you can only usefully reproject vector data. - John Powell

1 Answers

1
votes

I totally forgot to declare a projection when initializing the map object. Now it works like a charm.

map = new OpenLayers.Map('map', {
            projection: new OpenLayers.Projection("EPSG:3857")
        });