I have a layer with many features and when I add it to a map as WMS layer it works. But if I add the layer as WFS it seems there are no features.
The code I use to load WFS layer is:
var layerName = '...';
var workspace = '...';
var vectorLayer = new OpenLayers.Layer.Vector('questolayer', {
projection: new OpenLayers.Projection('EPSG:4326'),
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "/geoserver/wfs",
featureType: layerName,
featureNS: workspace,
srsName: "EPSG:4326"
})
});
vectorLayer.events.on({
'loadend': function(event) {
console.warn('00 features: ', vectorLayer.features);
}
});
openlayersmap.addLayer(vectorLayer);
If I check the response with Firebug I can see an XML with gml:featureMembers tags and many features into of it. But the warn message '00 features' in the log contains an empty vector.
Do you know why?
1 Answer 1
I found the issue! It was because the workspace was in uppercase in GeoServer. I convert to lowercase when I set the parameter in the protocol object and now it works. I don't know if this is a bug.