Skip to content

5.2. JSON

Uros Preloznik edited this page Jan 29, 2018 · 36 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 (add geocode or wsgi, not both!):

2.1 External Geocode service

IMPORTANT: MapZen announced shutting down its services on February 1, 2018. Plan is to switch this to MapBox, there is Open issue #70 about that. Until resolving and after February 1 this will not work!

Search combo does not depend on data in your project but works as external geocoding service. Currently this setting is for MapZen Search service. Example:

"geoCode": {
		"key": "YOUR MAPZEN API KEY",		
		"zoom": 19,
		"layers": "address",
		"sources": "openaddresses",
		"countryString": "AUT"
	}

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

3. Location services

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 and MapZen Elevation and Search 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": "mapzen"
	}]

For validating and formatting json text use online tool, for example JSONLint

You can check all this stuff in action in this demo: http://test.level2.si/gisapp/eu_demo?public=on&lang=en

For whole files look at helloworld.json and example from our demo eu_demo.json.

Clone this wiki locally