So, for people who will come across the same problem, this is the way I
solve it:
When you use the OpenLayers.Layer.Vector() method, you must specify the
readFormat in the OpenLayers.Protocol.WFS() method, like this:
protocol: new OpenLayers.Protocol.WFS(
{
srsName: "EPSG:2154"
,url: "http://192.168.168.199:81/geoserver/wfs"
,featureNS : "http://127.0.0.1:8080/wfs"
,featureType: "unit_pay"
,readFormat: new OpenLayers.Format.GML()
}
);
For GeoJSON, you must also specify the outputFormat like this:
,outputFormat: "json"
,readFormat: new OpenLayers.Format.GeoJSON()
And finally, an other problem that I met: the map projection. Your
features must be projected in the same projection as your map projection.
Otherwise, your features will not be displayed.
Hope it will help :)
Geoffrey
On Wed, 13 Jul 2011 10:27:21 +0200, gbrun <[email protected]> wrote:
Hi!
I have a quite incomprehensible error!
I try to display a WFS layer from GeoServer.
I tried two different ways by using Openlayers.Layer.WFS() and then
OpenLayers.Layer.Vector(). Only the first one works. This one uses a GET
protocol, and the second one a POST protocol (according to firebug).
What is really curious is that, even if no features are displayed in the
second case, the XML returned mentions no errors and lists the required
features. But when I look at my WFS layer variable in firebug, the
property "feature" is empty!
Above are my two codes:
var up_wfs = new OpenLayers.Layer.WFS(
"Unités paysagères en WFS",
"http://192.168.168.199:81/geoserver/wfs",
{typename:'unit_pay'}
);
var up_vector = new OpenLayers.Layer.Vector(
"Unités paysagères en vector",
{strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.WFS(
{
srsName: "EPSG:2154"
,url: "http://192.168.168.199:81/geoserver/wfs"
,featureNS : "http://127.0.0.1:8080/wfs"
,featureType: "unit_pay"
}
)}
);
Has someone any clue?
Geoffrey
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users