You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|` displaycrs: "EPSG:XXXX",`| Currently selected mouse coordinate display CRS. |
80
+
|` mapcrs: "EPSG:XXXX",`| The current map CRS. |
81
+
|` lang: "<code>",`| The current application language, i.e. en-US or en. |
82
+
|` cfgParams: <params>,`| Additional parameters passed in the theme search provider configuration, see below. |
83
+
|` limit: <number>,`| Result count limit. |
84
+
|` activeLayers: ["<layername>", ...],`| List of active layers in the map. |
85
+
| ` filterBBox: [xmin, ymin, xmax, ymax]|null,` | A filter bbox, in mapcrs, the search component may pass to the provider to narrow down the results. |
86
+
| ` filterPoly: [[x0, y0], [x1, y1], ...]|null` | A filter polygon, in mapcrs, the search component may pass to the provider to narrow down the results.|
87
+
|`}`||
88
88
89
-
* The format of the `results` list returned by `onSearch` is as follows:
90
-
```js
91
-
results = [
92
-
{
93
-
id:"<categoryid>", // Unique category ID
94
-
title:"<display_title>", // Text to display as group title in the search results
95
-
titlemsgid:"<display_title_msgid>", // Translation message id for group title, instead of "title"
96
-
resultCount:<result_count>, // Optional: true result count (i.e. not limited to the "limit" specified in searchParams).
97
-
priority: priority_nr, // Optional: search result group priority. Groups with higher priority are displayed first in the list.
98
-
type: SearchResultType.{PLACE|THEMELAYER|EXTERNALLAYER}, // Specifies the type of results. Default: SearchResultType.PLACE
99
-
items: [
100
-
// PLACE result
101
-
{
102
-
id:"<item_id>", // Unique item ID
103
-
text:"<display_text>", // Text to display as search result
104
-
label:"<map_marker_text>", // Optional, text to show next to the position marker on the map instead of `text`
105
-
x: x, // X coordinate of result
106
-
y: y, // Y coordinate of result
107
-
crs: crs, // CRS of result coordinates and bbox. If not specified, the current map crs is assumed.
108
-
bbox: [xmin, ymin, xmax, ymax], // Bounding box of result (if non-empty, map will zoom to this extent when selecting result)
109
-
geometry:<GeoJSON geometry>, // Optional, result geometry. Note: geometries may also be fetched separately via getResultGeometry.
110
-
thumbnail:"<thumbnail_url>", // Optional: thumbnail to display next to the search result text in the result list,
111
-
externalLink:"<url>"// Optional: a url to an external resource. If specified, a info icon is displayed in the result entry to open the link.
112
-
target:"<target>"// Optional: external link target, i.e. _blank or iframe
113
-
},
114
-
// THEMELAYER or EXTERNALLAYER result
115
-
{
116
-
id:"<item_id>", // Unique item ID
117
-
text:"<display_text>", // Text to display as search result
118
-
layer: {<layer_definition>} // Optional: layer definition, in the same format as a "sublayers" entry in themes.json. Layer definitions may also be fetched separately via getLayerDefinition.
119
-
info:<bool>, // Optional: Whether to display a info icon in the result list. The info is read from layer.abstract. If layer is not specified, the layer is fecthed via getLayerDefinition.
120
-
thumbnail:"<thumbnail_url>", // Optional: thumbnail to display next to the search result text in the result list,
121
-
sublayers: [{<sublayer>}, ...] // Optional: list of sublayers, in the format {id: "<item_id>", text: "<display_text>", has_info: <bool>, etc..}
122
-
}
123
-
]
124
-
}
125
-
]
126
-
```
89
+
*`axios` is passed for convenience so that providers can use the compiled-in `axios` library for network requests.
127
90
128
-
Consult [static/assets/searchProviders.js](https://github.com/qgis/qwc2-demo-app/blob/master/static/assets/searchProviders.js) for a full examples.
91
+
*`onSearch` is expected to return a list of search category results structured as follows:
|` title: "<display_title>",`| Text to display as group title in the search results. |
98
+
|` titlemsgid: "<display_title_msgid>",`| Translation message id for group title, instead of `title`. |
99
+
|` resultCount: <result_count>,`| Optional: true result count (i.e. not limited to the `limit` specified in searchParams). |
100
+
|` priority: <priority_nr>,`| Optional: search result group priority. Groups with higher priority are displayed first in the list. |
101
+
| ` type: SearchResultType.{PLACE|THEMELAYER|EXTERNALLAYER},` |Specifies the type of results. Defaults to `SearchResultType.PLACE`. |
102
+
|` items: [`||
103
+
|` {`| Format for `PLACE` result: |
104
+
|` id: "<item_id>",`| Unique item ID. |
105
+
|` text: "<display_text>",`| Text to display as search result. |
106
+
|` label: "<map_marker_text>",`| Optional, text to show next to the position marker on the map instead of `text`. |
107
+
|` x: <x>,`| X coordinate of result. |
108
+
|` y: <y>,`| Y coordinate of result |
109
+
|` crs: <crs>,`| CRS of result coordinates and bbox. If not specified, the current map crs is assumed. |
110
+
|` bbox: [xmin, ymin, xmax, ymax],`| Bounding box of result (if non-empty, map will zoom to this extent when selecting result). |
111
+
|` geometry: <GeoJSON geometry>,`| Optional, result geometry. Geometries may also be fetched separately via `getResultGeometry`. |
112
+
|` thumbnail: "<thumbnail_url>",`| Optional: thumbnail image to display next to the search result text in the result list. |
113
+
|` externalLink: "<url>",`| Optional: a url to an external resource. If specified, a info icon is displayed in the result entry to open the link. |
114
+
|` target: "<target>"`| Optional: external link target. Can be `_blank` (default) or `iframe`. |
115
+
|` },`||
116
+
|` {`| Format for `THEMELAYER` or `EXTERNALLAYER` result: |
117
+
|` id: "<item_id>",`| Unique item ID. |
118
+
|` text: "<display_text>",`| Text to display as search result. |
119
+
|` layer: {<layer_definition>},`| Optional, layer definition:., in the same format as a "sublayers" entry in themes.json. |
120
+
|| * For `THEMELAYER` results, the entry should be in the same format as a `sublayer` entry of a theme layer in `themes.json`. |
121
+
|| * For `EXTERNALLAYER` results, the entry can be of the form `{resource: "<resource_string>}` or a full layer definition. |
122
+
|| If `layer` is not specified, the layer definition will be queried via `getLayerDefinition`. |
123
+
|` info: <bool>,`| Optional: Whether to display a info icon in the result list. The info is read from `layer.abstract`. |
124
+
|` thumbnail: "<thumbnail_url>",`| Optional: thumbnail image to display next to the search result text in the result list. |
125
+
|` sublayers: [{<sublayer>}, ...]`| Optional: list of sublayers, in the same format as the format parent result item (i.e. `{id: "<item_id>", text: "<display_text>", layer: {<layer>}, ...}`). |
126
+
|` }`||
127
+
|` ]`||
128
+
|`}`||
129
+
130
+
Consult [static/assets/searchProviders.js](https://github.com/qgis/qwc2-demo-app/blob/master/static/assets/searchProviders.js) for a full example.
129
131
130
132
## Filtering <aname="filtering"></a>
131
133
@@ -160,22 +162,20 @@ Alternatively, you can also set `searchFilterRegions` to an URL returning a JSON
160
162
## Configuring theme search providers
161
163
162
164
For each theme item in `themesConfig.json`, you can define a list of search providers to enable for the theme as follows:
163
-
```json
164
-
...
165
-
searchProviders: [
166
-
"<providerkey1>", // Simple form
167
-
{ // Provider with custom params
168
-
"provider": "<providerkey2>",
169
-
"key": "<key>", // Optional: key to disambiguate multiple provider configurations of the same provider type (i.e. multiple `qgis` provider configurations)
170
-
"label": "<label>", // Optional: provider label (displayed in provider selection menu). If not specified, the label/labelmsgid from the provider definition is used.
|` "key": "<key>",`| Optional: key to disambiguate multiple provider configurations of the same provider type (i.e. multiple `qgis` provider configurations). |
173
+
|` "label": "<label>",`| Optional: provider label (displayed in provider selection menu). If not specified, the label/labelmsgid from the provider definition is used. |
|` "params": {...}`| Additional params passed to the provider `onSearch` function as `searchParams.cfgParams`. |
176
+
|` }`||
177
+
|`]`||
178
+
179
179
Note: The QWC stock application (also used by the `qwc-map-viewer` docker image) includes four providers by default: `coordinates`, `nominatim` (OpenStreetMap location search, see <ahref="#nominatim-search">below</a>), `qgis` (see <ahref="#qgis-search">below</a>) and `fulltext` (see <ahref="#fulltext-search">below</a>).
180
180
181
181
## Configuring the nominatim (OpenStreetMap) location search <aname="nominatim-search"></a>
0 commit comments