[OpenLayers-Users] Unable to display a vector WFS layer

Cyril Dejonghe cyril.dejonghe at free.fr
Mon Jan 30 09:39:33 EST 2012


Hi list !

I'm new to OpenLayers and I don't manage to display my WFS vector
layer on a OSM base layer.
So what I DO manage to do is :
- my WFS data are correctly set. I use Geoserver to provide WMS / WFS
for cadastral data.
- my js and my WMS server ARE running on the same webapp (as the final
application will be a JEE application, I use TOMCAT for both geoserver
and my app)
- I manage to display a WMS layer with the same data and transparency
- The request generated by OL and the answer of the geoserver seem
correct (some data are transfered, the GML format seems correct)

But if I don't display the WMS layer, I got nothing displayed for the WFS layer.
Last info on my conf :
- my WMS / WFS data are projected in Lambert93.
- i'm using OL 2.11 and GeoServer 2.1.3


So hope you don't mind a snippet of my code...

-----
carto = {
   projs : {
       wgs84: new OpenLayers.Projection("EPSG:4326"), // WGS84
       lambert93: new OpenLayers.Projection("EPSG:2154"),
       spherMercator: new OpenLayers.Projection("EPSG:900913")
   },
   map : undefined,
   layers : {},
   select : undefined,

   init : function() {
       carto.map = new OpenLayers.Map("map", {
           controls: [
               new OpenLayers.Control.Navigation(),
               new OpenLayers.Control.LayerSwitcher( {title: 'Choix
des calques visibles'})],
           projection: carto.projs.spherMercator,
           units: 'm',
           maxResolution: "auto",
           maxExtent: new OpenLayers.Bounds(-3.10, 48.75,-2.99,
48.82).transform(carto.projs.wgs84, carto.projs.spherMercator)
       });

       carto.layers.fond = new OpenLayers.Layer.OSM();

       carto.layers.ilotsWMS = new OpenLayers.Layer.WMS("ilotsWMS",
"http://localhost:8080/geoserver/wms",
           {'layers': 'cultureplus:ilot_2009_022',
'format':'image/png', 'transparent':'true'},
           {'opacity': 0.7, 'isBaseLayer': false, 'visibility': true});

       carto.layers.ilots = new OpenLayers.Layer.Vector("ilots", {
           style : {
               pointRadius: 16,
               strokeColor: "blue",
               strokeWidth: 3,
               cursor: "pointer"
           },
           strategies: [new OpenLayers.Strategy.BBOX()],
           protocol: new OpenLayers.Protocol.WFS({
               version: "1.1.0",
               srsName: "EPSG:2154",
               url: "http://localhost:8080/geoserver/wfs",
               featureType: "ilot_2009_022",
               featureNS: "http://www.openplans.org/topp",
               featurePrefix: "cultureplus",
               visibility : true
           })
       });

       carto.map.addLayer(carto.layers.fond);
       carto.map.addLayer(carto.layers.ilots);
       carto.map.addLayer(carto.layers.ilotsWMS);
       carto.map.setCenter(new
OpenLayers.LonLat(-3.05,48.78).transform(carto.projs.wgs84,
carto.projs.spherMercator), 13);
   }
}

Thanks for any help, i'm stuck on this first step...
--
Cyril.


More information about the Users mailing list