5.2. JSON

Uroš Preložnik edited this page Feb 2, 2019 · 26 revisions

Additional configuration can be done with project.json file beside project.qgs file. You can configure:

1. Search Panels

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",
		"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,
			"renderer": "customURLFormatter"
		}, {
			"header": "Country code",
			"dataIndex": "iso_cc",
			"menuDisabled": true
		}],
		"selectionLayer": "pop_places",
		"selectionZoom": 12,
		"doZoomToExtent": false
	}],

Description from original QWC.

2. Search Combo

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": "",
		"countryString": "AT",
		"provider": "mapbox"
	}

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"		
	}

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.

3. Location services

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.

You can’t perform that action at this time.
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.
Press h to open a hovercard with more details.