We set up a QGIS server and are using QGIS to connect to a WFS layer. Everything is working fine within the desktop application. Then we use qgis2leaf to generate a html/js web map. That all works fine, except when I use the WFS layer. For some reason I am getting the Unexpected token < error, as can be seen here (http://qgis.webmuni.com/export).

So basically what I think is happening is that the call that is made is (http://qgis.webmuni.com/qgis_mapserv.fcgi?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=zones2&SRSNAME=EPSG:4326&outputFormat=text/javascript&format_options=callback:processJSON) and it expects it to return JSON, but the server is returning XML.

I don't know why the server wont return JSON(P) and I am not sure if there is something I am doing wrong or if we need to configure the server in some way to enable JSON capabilities.


Got it figured out:

qgis2leaf used outputFormat=text/javascript, which for some reason was returning XML, but changing that to outputFormat=GeoJSON worked for me with QGIS server.

Hopefully this helps someone.

  • I wrote the WFS code for qgis2leaf, and I was using Geoserver, so that explains it. I don't know of a way to detect whether a QGIS WFS layer is Geoserver or something else such as QGIS Server. If we could work that out, I could fix this problem. – Tom Chadwin Nov 10 '15 at 15:25
  • By the way, qgis2leaf is no longer being developed. Try qgis2web instead. – Tom Chadwin Nov 10 '15 at 15:26

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.