2

I've built a web application using OpenLayers, which is connected to my PostGIS database through Geoserver. Now that I'm able to successfully display all of the layers, I'd like to add querying/interactivity capabilities to the map. For instance, I'd like to create a dropdown menu of checkboxes so the user could "Choose X who have done Y", another dropdown to "Choose X who haven't done Y", etc. I'm having trouble figuring out how exactly to add in this functionality. Does anybody know any good resources/examples for how I might go about doing this?

Thanks for your help.

1 Answer 1

3

Rather than using your client-side code to query your database (big security risk), I would suggest you use Geoserver's WFS filtering capabilities. Geoserver's WFS implementation supports a number of filtering techniques, including cross-layer filtering through the querylayer extension.

Here is an example implementation. The js in the source is not minified so it is readable.

4
  • Great - thank you very much! The filters might be exactly what I'm looking for. I'll give it a try.
    – Haynes
    Commented Aug 8, 2014 at 18:35
  • 2
    For those queries that are too complicated (using joins, or obscure database functions) to be expressed in WFS, you can use the "SQL Views" feature of GeoServer to access any SQL query. Commented Apr 9, 2015 at 16:55
  • @PaulRamsey, you mean create view in database from SQL query then connect to the view from Geoserver?
    – Jane
    Commented Apr 23, 2021 at 12:20
  • My queries are not very complicated, but there are many data in db - are the SQL views the best approach for filtering data and display filtered layers?
    – Jane
    Commented Apr 23, 2021 at 12:28

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.