I'm working on localhost:8080 and want to get WFS data in a Leaflet map. So, I've read in some posts here that I first I have to enable Jsonp in my web.xml file in Geoserver. So I put


But I can't see that Jsonp is allowed with a getCapabilities :

<ows:Parameter name="outputFormat">
<ows:Value>text/xml; subtype=gml/3.2</ows:Value>
<ows:Value>application/gml+xml; version=3.2</ows:Value>
<ows:Value>application/vnd.google-earth.kml xml</ows:Value>
<ows:Value>text/xml; subtype=gml/2.1.2</ows:Value>
<ows:Value>text/xml; subtype=gml/3.1.1</ows:Value>

Then, I tried to load my WFS data into a GeoJson layer in leaflet with this code :

<!DOCTYPE html>

<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta charset="utf-8" />
<title>Test WFS</title>        

<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>

<div id="map"></div>

var center = new L.LatLng(46.707, 4.678);
var map = new L.Map('map', { center: center, zoom: 14, minZoom:11});    

var owsrootUrl = 'http://localhost:8080/geoserver/Vin/ows';

var defaultParameters = {
    service : 'WFS',
    version : '2.0.0',
    request : 'GetFeature',
    typeName : 'Vin:vinChalon',
    maxFeatures : 50,
    outputFormat: 'json'

var parameters = L.Util.extend(defaultParameters);

var URL = owsrootUrl + L.Util.getParamString(parameters);

var ajax = $.ajax({
    url : URL,
    dataType : 'jsonp',
    jsonpCallback : 'getJson',
    success : WFSLayer

function WFSLayer(data) {
L.geoJson(data, {
style: function (feature) {
    return {color: 'black',
        fillColor: '#ff0000',
        fillOpacity: 0.10};


And firefox's console return

SyntaxError: missing ; before statement    ows:1:7

Is someone knows why it doesn't work ?

1 Answer 1


Have you restartet Tomcat / Geoserver after editing the web.xml?

Your capabilities should show this entry:


Your javascript-code seems ok. --> slightly adapted with an other Geoserver/Layer here: http://jsfiddle.net/expedio/u1oskkxy/

  • Many thanks for your reply Thomas B. Yes, now jsonp is allowed.
    – Hippipers
    Oct 13, 2015 at 10:27
  • But if I enclose my geoJson in my ajax function, it works, if not, like in your code, it doesn't works ...
    – Hippipers
    Oct 13, 2015 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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