-
Notifications
You must be signed in to change notification settings - Fork 31
5.2. JSON
Additional configuration can be done with project.json file beside project.qgs file. This file is also useful to override some global client settings defined in /client_common/settings.js
file. You can configure:
Note: Search panels work only in standard (desktop) client!
With this you define search options for data in QGIS project. Settings are the same as in original QWC, except you assign it to the "search"
property. Example with one tab (search property is array of objects, so you can just add more for new tabs):
"search": [{
"title": "Places",
"panelTitle": "Optional override panel title string from translation",
"useWmsRequest": true,
"queryLayer": "pop_places",
"formItems": [{
"xtype": "textfield",
"name": "name",
"fieldLabel": "Name",
"allowBlank": true,
"blankText": "Please enter a name",
"filterOp": "ILIKE"
}, {
"xtype": "textfield",
"name": "iso_cc",
"fieldLabel": "Country code",
"allowBlank": true,
"blankText": "Enter Country code (2 letters)",
"maxLength": 2,
"minLength": 2,
"filterOp": "ILIKE"
}, {
"xtype": "combo",
"name": "type",
"store": [
"National Capital",
"Provincial Capital",
"Large City",
"Town"
],
"fieldLabel": "Type",
"emptyText": "",
"typeAhead": false,
"forceSelection": true,
"selectOnFocus": true,
"filterOp": "="
}],
"gridColumns": [{
"header": "Name",
"dataIndex": "name",
"menuDisabled": true
}, {
"header": "Country code",
"dataIndex": "iso_cc",
"menuDisabled": true
}],
"selectionLayer": "pop_places",
"selectionZoom": 12,
"doZoomToExtent": false
}],
Description from original QWC.
Note: Search combo as external service and as local WSGI search works in both clients (desktop and mobile)!
Search combo box can be configured in one of two ways (as geocode or wsgi, not both!):
2.1 External Geocode service
Search combo does not depend on data in your project but works as external geocoding service. Currently this setting is for MapBox Geocoding service. Example:
"geoCode": {
"zoom": 19,
"layers": "",
"country": "AT",
"provider": "mapbox",
"language": "sl"
}
2.2 WSGI Search on PostgreSQL/Postgis data
This enables one line search combo on your Postgis tables. Read here about installation needed and how must data tables be prepared.
"wsgi": {
"searchtables": "search_pop_places,search_airports,search_admin",
"emptytext": "Optional project specific empty text string here",
"limit": 50, //Optional parameter to limit results from each searchtable, if skipped 10 will be used
"filter": "Optional value to filter results, searchtables must contain field name 'filter'",
"connect": "Optional python database connection string that must exist in wsgi folder, default qwc_connect.py"
}
Table structure and views definition for above example
This is also visible in live demo
WSGI ON WINDOWS: For some reason is really hard to setup WSGI on Windows and our recommendation is don't bother. If you have to stay on Windows and need search on local databases then only way is to port python code for WSGI to PHP. Contact us for details.
IMPORTANT: MapZen announced shutting down its services on February 1, 2018. So now only supported provider for this is MapBox!.
Every GetFeatureInfo (identify) can also fire defined location services to various external API's. Call elevation service to get height of current point or address service to get nearest address. Currently supported API's are MapBox Surface and Geocoding API. Calls are made from client directly so note this:
- your API keys are visible through network traffic,
- API service must support Cross origin requests (CORS).
"locationServices": [{
"name": "elevation",
"key": "YOUR API KEY",
"provider": "mapbox"
}, {
"name": "address",
"key": "YOUR API KEY",
"provider": "mapbox"
}]
For validating and formatting json text use online tool, for example JSONLint
You can check all this stuff in action in this demo: https://test.level2.si/gisapp/eu_demo?public=on
For whole files look at helloworld.json and example from our demo eu_demo.json.