.. _popup: Popup ===== .. contents:: :depth: 3 Activate popup --------------- With the plugin, you can activate popups for a **layer** or for a **group** configured with the :guilabel:`Group as layer` option. In the :guilabel:`Layers` tab, click on the :guilabel:`Popup` checkbox. .. image:: /images/publish-link.jpg :align: center For the :guilabel:`Group as layer` option you must select the option for the group and for all the layers included you want to show in the popup: in this case, only the layers with the option :guilabel:`Popup` checked will be shown. You have three types of popup sources: * ``Automatic``, read :ref:`auto-popup` * ``Lizmap HTML``, read :ref:`lizmap-popup` * ``QGIS HTML Maptip``, read :ref:`qgis-popup` * ``QGIS Drag&Drop form``, read :ref:`form-popup` In Lizmap Web Client, a click on a feature will trigger the popup if (and only if): * the popup **has been activated** * through the plugin for the layer or the group * or the layer has edition capabilities for existing features * the layer is **active in the legend**, so that it is shown on the canvas * the user has clicked on an **area of the canvas** where data for the layer with active popups are displayed. .. note:: For point layers you need to click in the middle of the point to display the popup. The tolerance can be setup in :menuselection:`Lizmap plugin --> Map options --> Map tools`. You can update where the popup is displayed in the web interface in :menuselection:`Lizmap plugin --> Map options --> Map interface`. You can choose between: * ``dock`` * ``minidock`` * ``map`` * ``bottomdock`` * ``right-dock`` Geometry of the feature ----------------------- See :ref:`project_wms` for adding the geometry. Media in popup -------------- See :ref:`use-in-popups` in the **media** chapter. .. _auto-popup: Automatic popup --------------- The Lizmap Web Client ``Automatic`` popup displays a table showing the columns of the attribute table in two columns *Field* and *Value*, as shown below: ============ ============== Field Value ============ ============== id 1 name A name description This object ... photo :-) ============ ============== You can modify the info displayed through QGIS, and also display pictures or links. Simple popup configuration ____________________________ With the plugin, if you click on the checkbox **Activate popups** without modifying its content through the button *Configure* the default table is shown. Nevertheless, you can tune several things in QGIS and with the help of Lizmap plugin to **parametrize the fields displayed**, **rename fields**, and even **display images, photos, or links to internal or external documents**. Mask or rename a column _______________________ .. warning:: This is working only using `Lizmap` or `Auto` popup. The `QGIS` popup follows the QGIS maptip. You need to use the :menuselection:`Layer Properties --> Fields` tab in QGIS: * to **hide** a column in the popup, uncheck the corresponding WMS checkbox. The WMS column is on the right of the table. This will hide the field in QGIS Server from any WMS requests. * to **rename** a column, you should use the alias column. But to edit this column, add it from the tab :menuselection:`Layer Properties --> Attributes Form`. .. image:: /images/features-popup-fields.jpg :align: center :width: 70% Usage of media: images, documents, etc. _______________________________________ If you want to use some media in your popup (pictures, PDF documents…) in your popup, you must use the :ref:`media` directory. For a given feature, using a path in your field starting by ``media/``, Lizmap will display: * **the image itself** for jpeg or png files * **the content** for txt or HTML files * **a link** to any other file extension .. seealso:: Chapter :ref:`media` for more details on the usage of documents of the directory media in the popups. Usage of external links _______________________ You can also use, in a field, **full web links to a specific page or image**: * the image referred to will be displayed, instead of the links * the web link will be displayed and clickable .. _lizmap-popup: Lizmap HTML popup ----------------- Introduction ____________ If the simple table display does not suit your needs, you can write a **popup template**. To do so, you should know some **HTML format**. See e.g.: https://www.w3schools.com/html/ .. warning:: When you use the *Lizmap HTML* mode, the previous configuration to rename a field does not work anymore: you have to configure what is displayed and how through the template. Managing media is also possible, but you have to configure it as well. Deploying _________ You can edit the popup template with the button *Configure* in the Lizmap plugin. Clicking on it you'll get a window with two text areas: * an **area where you can type your text** * a **read-only area**, showing a preview of your template .. image:: /images/features-popup-configure.jpg :align: center :width: 70% You can type simple text, but we suggest to write in HTML format to give proper formatting. For instance, you can add paragraphs, headings, etc.: .. code-block:: html
An example of paragraph
The behaviour is as follows: * if the content of the two areas is empty, a simple table will be shown in the popup (default template) * if the content is not empty, its content will be used as a template for the popup Lizmap Web Client will replace automatically a variable, identified by the name of a field, with its content. To add the content of a column to a popup, you should use the name of the column precede by a dollar sign (`$`), all surrounded by curly brackets (`{}`). For instance: .. code-block:: htmlAn example of paragraph
A name: {$name}
Description: {$description}
.. note:: If you have configured an alias for a field, you have to use the alias instead of the name, between the brackets. You can also use the values of the columns as parameters to give styling to the text. An example here, to use the colour of a bus line as a background colour: .. code-block:: htmlLINE : {$ref} - {$name}
Usage of media and external links _________________________________ You can **use the media** referred to in the table content, even if you use a *template model*. To do this, you should use the media column, taking into account the fact that Lizmap Web Client automatically replaces the relative path of the type ``/media/myfile.jpg`` with the full URL to the file, accessible through the web interface. You can also use full URLs pointing to the pages or images on another server. Here an example of a template handling media and an external link: .. code-block:: htmlA Title
The name is {$name}
A sample image
5000, 'red', 'black') %]">[% POPULATION %]
.. _print-layout-atlas: Link to a PDF layout using the QGIS Atlas ----------------------------------------- .. note:: The QGIS server `AtlasPrint |
|
|
---|---|---|