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

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

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


or however yours is setup.

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

| improve this answer | |
  • The file with this javascript is accessed via a web server. – Trond Thorbjørnsen Aug 7 '13 at 7:29
  • OK! Now I understand: I can't access the wfs data from another web server, I have to have the html file on the geoserver web server. – Trond Thorbjørnsen Aug 7 '13 at 9:39
  • 4
    @GISer "I've seen this answered quite a bit on here." Really? This is the only post I've seen that specifically targets OL3. Wouldn't mind seeing some better documentation on this as the OL3 documentation is still very much a work in progress. – Kyle Jan 13 '14 at 18:36
  • 1
    This does not make sense. Are you saying if you have remote GeoJSON data that it has to run on the same server that serves the map? If you see some of the OpenLayers examples on their website, the spatial data does not have to reside on the same server as the map server displaying the data. – user3657279 Sep 9 '14 at 20:35

I agree with Kyle. Even a year later it took me a while to find good examples with explanation which can be easily reproduced.

I do like the examples from the 'the book of openlayers 3'. Unfortunately I do not have access to the book itself but I believe it to be well written judging from the examples.

This example is for ol 3.4


I had some problems replicating the ol 3.5 vector-wfs master example from the openlayers examples page. These problems are probably fixed by now.


I created three jsfiddle to demonstrate ol 3.5.0 calls via AJAX for ol.format.GeoJSON (JSON and JSONP) as well as ol.format.WFS.

WFS (CORS access has to enabled on the web server, e.g. for Apache Tomcat)


JSON (CORS access has to enabled on the web server, e.g. for Apache Tomcat)


JSONP (JSONP needs to be enabled in Geoserver)


| improve this answer | |
  • Well, the answer did come two years after the accepted answer, and the accepted answer was correct as far as it went. But this is much more useful. – Auspex Jan 26 '17 at 15:23

I think what you need is this:
REST configuration API reference
With REST you can call data between servers (or between e.g. Apache on port 80 and geoserver in port 8080 if it's the same server).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.