I want to create a web gis application (Leaflet/GeoServer). I need to add a functionality of search in a WMS layer.

I managed it up to know to display properties when the user clicks on the map. For this I build a URL like the following if a user click on the map:

&query_layers= Teslayer

As result I get something like this what I show formattted in a popup on the map.

    "type": "FeatureCollection",
    "features": [{
            "type": "Feature",
            "id": "38256",
            "geometry": {
                "type": "Polygon",
                "coordinates": [[[363732.531, 5846236], ...]]
            "geometry_name": "shape",
            "properties": {
                "id": "AL650005OGOC",
                "id_hash": "4556ae4b8bc2eb20835f72147516",
                "area": 11959.645203521419,
                "fln": 13,
                "flnname": test,
                "arz": false,
                "rbv": null,
                "zfm": null,
                "obkx": 363729.941,
                "obky": 5846330.941,
                "zde": "1000-01-01",
                "gkz_lan": "12",
                "gkz_rbz": "0",
                "gkz_krs": "65",
                "gkz_gem": "165",
                "gkz_gmt": null,
    "totalFeatures": "unknown",
    "numberReturned": 1,
    "timeStamp": "2019-11-27T09:59:00.073Z",
    "crs": {
        "type": "name",
        "properties": {
            "name": "urn:ogc:def:crs:EPSG::25833"

The next step is now to make it possible to search on this WMS Layer. My plan is to offer the user a dropdown where he can first choose between all the values of the flnname property. If he has made a choice, he should be shown all the places on the map where flnname is assigned to the selected value.

So far I have tested this plugin: https://github.com/stefanocudini/leaflet-search. If I understand that correctly, a search with this plugin is only possible if markers with Leaflet are positioned on a layer. A search in a WMS layer is not possible.

The problem is that I want this functionality using WMS or JavaScript. PHP is not installed.

PostGIS is installed. This would be a possibility. But so far I have no experience with PostGIS.

How is this be possible using WMS?

  • What type of search do you want to do, and what sort of results are you expecting? A search in a WMS layer is generally not possible as output is image/video format (or generalized vector), but what about a query to the underlying data using SLD, and output as map?
    – nmtoken
    Nov 27 '19 at 12:59

Searching is possible with WFS, with WMS is not possible as WMS only gives image. Since GeoServer is used WFS should be available. With WFS you can query features with certain property values like this


The leaflet-search plugin can be configured to use AJAX queries to this URL. So when the user selects a property, an AJAX query of the above structure will be sent with the selection substituted in property = attribute e.g. flmname=test.

More info on WFS: https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#getfeature


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.