WFS support in Cesium


I had previously enquired about WFS support in Cesium here.!msg/cesium-dev/QUUxLZCsQdw/-M_XIWlxBgAJ

By using some of the code in the pending pull request on GmlDataSource I have begun
working on a WFS ImageryProvider that can query a server for feature info and then
render the features.
See :

I have the provider able to query and render simple features published as vector layers in Geoserver.
I was hoping to integrate this module into the Cesium tree.
I would appreciate any help in adding more features to the module that users see fit.

Sushrut Shivaswamy

Hi Sushrut,

I want to try your code. Can you tell me how to integrate it into Cesium?
Should I just put the WebFeatureServiceImageryProvider.js file somewhere in source code folders? I've put it in Source/Scene and wrote code for initialization in sandcastle, but an error occurs

//initialise cesium
var viewer = new Cesium.Viewer("cesiumContainer");

//initialise WFS provider
     var wfs = new Cesium.WebFeatureServiceImageryProvider({

          url : "http://localhost:8080/geoserver/xxxxxx",
          layers : "xxxxxx",
          viewer : viewer

Uncaught TypeError: Cesium.WebFeatureServiceImageryProvider is not a constructor (on line 5)

Hi Paula,

The wfs plugin file should be included in your main html page in a script tasg after the cesium.js file.


Sushrut Shivaswamy

Hi Sushrut,

thank you for quick answer and help, but I still don't manage to make the plugin work. I'm not very experienced in programming and I don't understand what do you mean by including the plugin in main html page in a script tags. I see there are Cesium.js and main.js files in Source folder but there's no main.html file. I've included the WebFeatureServiceImageryProvider in Cesium.js that looks like this:

define(['./Core/appendForwardSlash', './Core/arrayFill', *...LOTS OF SIMILAR CODE...*
, './Scene/WebFeatureServiceImageryProvider', *LOTS OF SIMILAR CODE*
Scene_WebFeatureServiceImageryProvider, *LOTS OF SIMILAR CODE*
Cesium['WebFeatureServiceImageryProvider'] = Scene_WebFeatureServiceImageryProvider; *LOTS OF SIMILAR CODE*

I haven't changed anything in sandcastle code except the url. Do I have to put something there?

Thank you again and best regards,

Hi Paula,

The code hosted on github can be used in two ways.

By integrating the WFS module in Cesium source or using it as a plugin.

I would you suggest you stick to the second approach and use WFS as a plugin

since it does not involve changing the source code.

You can download the plugin from here :

The file will need to be included in the main html page of your app.

I’m not sure how that works in sandcastle but in a basic webpage you would have something like

// instantiate the cesium globe var viewer = new Cesium.Viewer('viewer'); // . create the wfs getter to load a vector layer on the globe. var wfs = new Cesium.WebFeatureServiceImageryProvider({ url : "[http://localhost:8080/geoserver/web](http://localhost:8080/geoserver/web)", layers : "vectorLayerName", viewer : viewer }); Hope that makes sense. Regards, Sushrut Shivaswamy

Hi Sushrut,

I've followed your advice, but still getting "Uncaught TypeError: Cesium.WebFeatureServiceImageryProvider is not a constructor (on line 4)".
Do you have any idea why is that so and how can I fix that?
Do I have to put WFS.js in a particular folder or it doesn't matter where I put it (like can I put it for example on Desktop)?
Also, you mentioned Cesium.js script tag but in examples from sandcastle there is only Sandcastle-header.js script tag like in the code below.

Thank you so much and sorry for bothering you,

You need to specify the relative path to WFS.js as has has been done for Sandcastle-header.js not the file system path.

OK, now I've put the WFS.js in Source/Scene and wrote relative path -> "../../../Source/Scene/WFS.js" but still getting the same error

Hai paula iam also facing the same issue .. are you able to fix it or is their any other way?

I haven’t personally used this module, but from a quick search on the forum, it looks like TerriaJS (a library built on top of CesiumJS) supports WFS, see: