[GIS] Displaying WFS layer in OpenLayers 3

boundless-suitegeoserveropenlayerswfs

I'm working with GeoServer and OpenLayers 3, I have a hosted layer in GeoServer that I want displayed using OpenLayers 3 as a WFS layer.

It doesn't show any errors, but I don't get the map. It works with WMS, but not with WFS. Please can anyone help me to fix that?

This is my code:

var v=new ol.layer.Vector({
           source: new ol.source.Vector({
                format: new ol.format.WFS({
                    version: "1.1.0",
                    url: "http://localhost:8080/geoserver/wfs",
                    featurePrefix: "opengeo", //workspace
                    featureType: "opengeo:region_geo", //layer name
                    featureNS: "http://yourdomain/application/catalogLayer", 
                    geometryName: "geom",  //feature name in database
                })
            })  
});
var map = new ol.Map({
          target: 'map-id',
                  layers: [
                            v              
              ],
 view: new ol.View({
 projection: 'EPSG:4326',
      center: [0, 0],
      zoom: 1
    })         
     });

I get this result :

enter image description here

Best Answer

I had the same problem, and it worked fine after I took my project and put it in ./'Data directory'/www/

After that when I access the WFS from 'http://localhost:8080/geoserver/www/Myproject' using the OL3 example it works fine.