The filtering feature presented allows you to filter the data displayed on the map based on the logged in user. It is possible to filter only vector layers because Lizmap uses a column in the attribute table.
Filtering currently uses the ID of the user group connected. It’s active for all requests to QGIS server, and thus concerns:
- the vector layers images displayed on the map
- the popups. See Popup
- the Locate by layer feature lists. See Localizzare attraverso un livello
- drop-down lists of Editing forms from Value relation. See Edition
- the attribute table display etc
There are two kinds of filtering :
- based on attributes
- based on spatial relationship
In this panel, we can:
- configure a polygon layer to use for spatial filtering
- configure layers which must be filtered by the filtering layer
This is a feature in Lizmap 3.5.
The Lizmap plugin in QGIS Server must be installed with at least Lizmap QGIS plugin 3.6. Otherwise, the filter won’t work and all data will be visible.
Choose the polygon layer used for filtering
Choose the field in this layer which has Lizmap groups, separated by a comma.
Add a layer to filter to this tool:
- Click the button.
- Choose the layer to filter
- Choose the primary key of the layer
- Choose if the filtering if for both visualisation and editing or only editing
- Choose either intersection or contain spatial relationship.
- To edit a layer in the table, select it and click the button or double click on the row.
- To remove a layer from the table, select it and click the button.
For your information, performance will be better when using PostgreSQL layers : either filtering or filtered layers or both.
To use data filtering tool in Lizmap Web Client, you must:
- have access to the administration interface of Lizmap Web Client
Here are the detailed steps to configure this feature:
In Lizmap Web Client administration, in the repository properties, be sure that
anonymous and other relevant groups are not checked
for Always see complete layers data, even if filtered by login. See Definire i diritti per ogni gruppo.
Check group ID or user ID in the administration interface:
- To know group ID, you must go to the administration interface Groups of new users) : ID appears in parentheses after the name of each group (under the title
- Or to know the user ID, just use its login.
For all vector layers which is desired filter data, just add a text column that will hold the ID for each line who has the right to display this feature.
- Fill this column for each line of the attribute table with the ID (using the calculator, for example).
- It is possible to set
allas the value in some lines to disable the filter: All users will see the data for these lines.
- If the value in this column for a row does not correspond to a user group, then the data will be displayed for no user.
Add the layer in the table Filter Data by User panel:
- Click the button.
- Select layer from the dropdown list
- Select the field with the ID
- Check the box if the field contains user ID, instead of group ID
To edit a layer in the table, select it and click the button or double click on the row.
To remove a layer from the table, select it and click the button.
Disable the client cache and cache server for all filtered layers. Otherwise, the data displayed will not be updated between each connection or user logout!