[GIS] How to use WFS from Geoserver with OpenLayers 3

geoserverjavascriptopenlayerswfs

I have tried with different setups and formats, but no success.

With firebug, I can see that the json data is loaded, but nothing shows up on the map.

Have anyone experience with geoserver and wfs in openlayers 3?

var layer_ojd_vector = new ol.layer.Vector({
 source: new ol.source.Vector({
  parser: new ol.parser.GeoJSON(),
  url: http://SERVER:8080/geoserver/NS/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=NS:LAYER&maxFeatures=50&outputFormat=json
 }),
 style: new ol.style.Style({rules: [
  new ol.style.Rule({
   filter: 'geometryType("point")',
   symbolizers: [
     new ol.style.Shape({
       fillColor: '#013',
       size: 40
     })
   ]
 })
]})  
});

Best Answer

I've seen this answered quite a bit on here.

You must run the HTML file from a webserver and access by:

SERVER:8080/geoserver/index.html

or however yours is setup.

You can't simply double click the HTML file and view the WFS layer.