Frequently Asked Question

Setup a customized search in QGIS Cloud Web Client
Last Updated 7 years ago

You can configure the SQL query performed when searching in the map:

  • Go to:
  • Select "Maps"
  • Choose your map and click on the pen-icon
  • Scroll down to Search Type and switch the "Searchtype" to DBSearch
  • Enter the name of the QGISCloud Database you want to search in "Search db" (the Database names are visible in the QGIS Cloud plugin, under "Account")
  • Enter an appropriate SQL statement in the "search sql" field. Your SQL statement must return a string called displaytext and a bounding box called bbox. 
So the SQL statement would look something like:

SELECT name AS displaytext, Box2D(wkb_geometry) AS bbox FROM <table> WHERE name ILIKE '%?%';

Name is a column containing some strings, wkb_geometry a column containing geometries, tablename is the name of the table (aka layer) you want to search, and %?% is the place holder for the search string.

If you would like to use special characters or upper case characters for columnnames or tablenames you have to quote them with "" - double quotes!

You can combine more than one column for search like:SELECT name||' - '||numver::text AS displaytext ...

Note that the CRS of BBOX must be the same as in the project. You may need to make a coordinate transformation like

... Box2D(st_transform(<geometry column>, <CRS>)) ... .

You can make your life much easier when you define a search view in the selected DB which you can manage with PgAdmin3 or QGIS DB Manager: 

CREATE OR REPLACE VIEW myserach as SELECT name AS displaytext, Box2D(wkb_geometry) AS bbox FROM <table> WHERE name ILIKE '%?%';

Than use this view for the search query box instead of a very complex SQL query:

select displaytext, bbox from mysearch where name ILIKE '%?%';

If you like to change the search query, you can do this very comfortable with PgAdmin3 or QGIS DB Manager. If you use this option there is no need to change the query in the QGIS Cloud backend

Here you find info how get the your DB-connection for connecting with PgAdmin3.
This option is only available with a QGIS Cloud Pro account.

Please Wait!

Please wait... it will take a second!