[OSGeo Africa] Leaflet User Input

Cameron Muller mullerc24 at gmail.com
Tue Mar 7 11:59:54 PST 2017


Evening all,

I was hesitant to post this here but I am at the end of the road after
seeking help on both Stack Overflow and a Google Group prior to this.

Please could I gain some assistance with the following problem - I would
like to create a CQL filter in Leaflet which filters data from GeoServer
based on user input, with the data hosted in a PostGIS database. I am
displaying my layers as WMS, and although I was able to get an interactive
filter working in Openlayers 3, I still have had no luck with Leaflet.

I have managed to get the 'static' cql_filter as suggested within my code
as below:

var contours = L.tileLayer.wms('http://gis01-dbn:8080/geoserver/Inyaninga_243-198/wms',
{
        layers: 'Inyaninga_243-198:contours_3857',
        format: 'image/png',
        transparent: true,
        cql_filter: 'elevation= 126',
        });

Is there however any way to make this elevation parameter receive user
input and update?

I have created a form in the html as such:

<form>
   Elevation(m):<br>
   <input type="text" id="myInput">
   <input type="button" value="Elevation">
</form>

However, I am getting stuck with passing "myInput" into the cql_filter to
accept a value which the user can enter. I have also tried creating a
function housing the cql_filter but again cannot call this into the
cql_filter option when loading the WMS layer.

I am new to the web development side of GIS, and currently in the process
of self studying this, any help or pointers in the right direction would be
greatly appreciated.

Kind regards,
Cameron Muller
Master of Science: Environmental Sciences
GISc Technician (GT 1770)
072 686 9200
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/africa/attachments/20170307/0cb30c0d/attachment.html>


More information about the Africa mailing list