Currently passing a Geoserver cql_filter to leaflet with a form and button but getting an error of "ReferenceError: DWITHIN is not defined" returned back from the browser when clicking the button my function is attached to.

My function is in a seperate javascript file:

    //Pylon Search Button
    function updatePylons() {
            var pylonFilter = DWITHIN(geom,collectGeometries(queryCollection('Inyaninga_243-198:proposed_pylons_3857','geom',"id = '" + document.getElementById("Pylon").value + "'")),0.05,kilometers);
            return proposed_pylons.setParams({CQL_FILTER:pylonFilter});

The form in the html:

    <input type="text" id="Pylon">
    <input type="number" id="distance">
    <input type="button" value="Filter" onclick="updatePylons()">

Anyone had any experience with this? The form parameters are meant to pass to the cql_filter as user input and then update when the button is clicked. However, the DWITHIN is not defined error occurs when clicking the button.

  • Is DWITHIN a javascript function in your code base? Mar 29, 2017 at 11:26
  • Hi there yes it is in my code base.
    – WhaleShark
    Mar 29, 2017 at 11:31
  • Please share the full request being sent to Geoserver. Or is it not even reaching that point? Mar 30, 2017 at 7:27
  • I have managed to get past the undefined DWITHIN error, however now when I query my WMS layer is completely removed as soon as I click the button my function is attached too.
    – WhaleShark
    Mar 30, 2017 at 7:52
  • The Geoserver request is: GET /geoserver//wms?service=WMS&request=GetMap&layers=Inyaninga_243-198%3Aproposed_pylons_3857&styles=&format=image%2Fpng&transparent=true&version=1.1.1&height=256&width=256&srs=EPSG%3A3857&CQL_FILTER=DWITHIN(geom%2C%20collectGeometries(queryCollection(%27Inyaninga_243-198%3Aproposed_pylons_3857%27%2C%27geom%27%2C%27id%20%3D%20%27%27EP1%27%27%20%27))%2C%205000%2C%20meters)&bbox=3502650.384139917,-3473298.56527841,3512434.3237604196,-3463514.625657907 HTTP/1.1
    – WhaleShark
    Mar 30, 2017 at 7:54

1 Answer 1


By copy-pasting the URL that you copy-pasted into your comments, I noticed that your request is full of zero-width unprintable characters:

enter image description here

E2 80 8C is the UTF8 sequence for the unicode code point U+200C, which is ZERO WIDTH NON-JOINER, and E2 80 8B is ZERO WIDTH SPACE.

There is something in your code adding those control characters every 22 characters in the URL string. Find that, set it on fire (figuratively), and the problem should disappear.

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.