new module:FieldLabels(wfs, lizmap3opt, ttlopt)
Create the cache of the labels.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
wfs |
object | The WFS module, with a getFeature method |
|
lizmap3 |
object |
<optional> |
The legacy lizMap object, to listen to the edition events |
ttl |
number |
<optional> |
The time to live of the cached labels, in milliseconds |
- Source:
Classes
Members
(static, constant) DEFAULT_TTL :number
The default time to live of the cached labels, in milliseconds.
Type:
- number
- Source:
(static, constant) MAX_FILTERED_CODES :number
The maximum number of codes requested with a filter on their values. Above, the labels of the whole source layer are requested.
Type:
- number
- Source:
Methods
clear()
Remove all the cached labels.
- Source:
getLabels(source) → {Promise.<object>}
Get the labels of the codes, from the cache or from the source layer.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
FieldLabelsSource | The source of the labels |
- Source:
Returns:
The labels by code
- Type
- Promise.<object>
invalidate(layerId)
Remove the cached labels of a source layer.
Parameters:
| Name | Type | Description |
|---|---|---|
layerId |
string | The source layer id |
- Source:
(static) buildExpFilter(source) → {string}
Build the expression filter of the labels request.
The filter of the source layer is combined with a filter on the codes, when the codes are given and are not too many.
Parameters:
| Name | Type | Description |
|---|---|---|
source |
FieldLabelsSource | The source of the labels |
- Source:
Returns:
The expression filter, empty if there is no filter
- Type
- string
(static) quoteString(value) → {string}
Quote a value as a string of an expression filter.
The single quotes are doubled: the literal is valid for QGIS Server and PostgreSQL, which converts it to the type of the compared field.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | number | The value to quote |
- Source:
Returns:
The quoted value
- Type
- string
Type Definitions
FieldLabelsSource
Type:
- object
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
layerId |
string | The source layer id |
|
typeName |
string | The WFS type name of the source layer |
|
codeField |
string | The field containing the codes |
|
labelField |
string | The field containing the labels |
|
expFilter |
string |
<optional> |
The expression filter of the source layer, if any |
codes |
Array |
<optional> |
The codes to get the labels of, all the codes if not given |
- Source: