Thank you Filip
Did somebody test openLayers add-on with a Geoserver WMS? I really don’t understand what is going on in my application. I will explain the context and post the codes, hoping that someone figures out what the problem is …
Data:
SHP data, named “my_data” in EPSG:900913 projection was imported into a PostGIS 1.5 database.
my_data was published into a Geoserver 2.1.4.
my_data is used in an openLayers map as a WMS.
Map:
OpenLayers map with EPSG:900913 projection.
the map contains an OSM layer the WMS layer of my_data.
the WMS is added to the map before the OSM layer.
Problem:
the WMS layer is displayed in EPSG:4326 instead of EPSG:900913.
when I switch from the WMS layer to the OSM layer, the display is no more on the right position: the OSM layer is centered on the Atlantic Ocean.
Surprise:
the same code written in Vaadin was translated to OpenLayers Javascript / HTML and no problem is detected. Everything is displayed where it should.
Guess:
Maybe there is a special projections configuration that should be done in Vaadin, in order to have everything right?!
Code used in Vaadin:
private final OpenLayersMap map = new OpenLayersMap();
map.setImmediate(true);
map.addControl(Control.Navigation);
map.addControl(Control.OverviewMap);
map.addControl(Control.MousePosition);
map.addControl(Control.LayerSwitcher);
map.addControl(Control.ScaleLine);
map.setApiProjection("EPSG:900913");
final OpenStreetMapLayer osm = new OpenStreetMapLayer();
WebMapServiceLayer wms = new WebMapServiceLayer();
wms.setUri("http://10.3.9.151:8080/geoserver/wms");
wms.setLayers("baboa");
wms.setProjection("EPSG:900913");
wms.setDisplayName("Geoserver");
wms.setTransparent(true);
wms.setFormat("image/png");
wms.setBaseLayer(true);
map.addLayer(wms);
map.addLayer(osm);
map.setCenter(246498, 6238585);
map.setZoom(13);
map.setWidth("100%");
map.setHeight("775px");
Code used in Javascript:
map = new OpenLayers.Map ('map', {
controls:[new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.OverviewMap(),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.Navigation()],
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:900913")
});
var osm = new OpenLayers.Layer.OSM();
var wms = new OpenLayers.Layer.WMS(
"Geoserver", "http://10.3.9.151:8080/geoserver/wms",
{
srs: 'EPSG:900913',
layers: 'baboa',
transparent:"true",
format: 'image/png',
isBaseLayer: 'true'
});
map.addLayer(wms);
map.addLayer(osm);
lonlat = new OpenLayers.LonLat(246498, 6238585);
map.setCenter(lonlat, 13, true, true);
I hope somebody sees where the problem is!
Regards.