WFS Search - geosolutions-it/MapStore GitHub Wiki

Introduction

This plugin allow a textual case insensitive search using a WFS service. Perform a WFS getFeature with cql filters to allow adding markers on the map on the feature position.

Configuration

The plugin can be configured using the outputConfig field to inject the configuration of the WFSSearchComboBox widget used by this plugin.

  • updateField: the field used as geometry
  • markerFadeoutEnable: Set to false in order to enable marker fadeOut (default to true),
  • separator: add a separator like | at the start or the end of the tools. can be "start" "end" or false (no separator)
  • noButton: forces the plugin to do not add the button, also if markerFadeoutEnable is false (useful if you have multiple instances of this plugin and you want to use only one button to remove all the markers)
  • zoom: the zoom level to use if the geometry has not a computable bbox (e.g. points) when you select a feature.
  • outputConfig: the widget configuration
    • url: the URL of the WFS service
    • typeName: the layer to query
    • recordModel: the model of the record. Maps the getFeature entries with localFields.
    • sortBy: field to use to sort results (a sorting field is required to allow pagination
    • queriableAttributes: attributes to use in the cql filter of the request to perform textual query
    • displayField: field to show if no template is specified
    • pageSize: page size of the request (default 10)
    • tpl: Extjs XTemplate to have show results (use fields specified in recordModel configuration)
    • width: dimension of the widget.

This is a sample configuration uses the geoserver sample data

   {
	  "ptype":"gxp_wfssearchbox",
	  "outputConfig":{
		 "url":"http://localhost:8080/geoserver/sf/ows?",
		 "typeName":"sf:archsites",
		 "recordModel":[
			{
			   "name":"cat",
			   "mapping":"properties.cat"
			},
			{
			   "name":"geometry",
			   "mapping":"geometry"
			},
			
			{
			   "name":"str1",
			   "mapping":"properties.str1"
			}
		 ],
		 "sortBy":"cat",
		 "queriableAttributes":[
			"str1",
			"cat"
		 ],
		 "displayField":"cat",
		 "pageSize":10,
		 "width":250,
		 "tpl":"<tpl for=\".\"><div class=\"search-item\"><h3>{cat}</span></h3>{str1}</div></tpl>"
	  },
	  "updateField":"geometry",
	  "zoom":18,
	  "outputTarget":"paneltbar",
	  "index":30
   },

The configuration above will perform a WFS GetFeature request with the parameters below :

startindex:0
maxfeatures:10
service:WFS
version:1.1.0
request:GetFeature
typeName:sf:archsites
outputFormat:json
sortBy:cat
cql_filter:(str1 LIKE '%Bob%') OR (cat LIKE '%Bob%')
srsName:EPSG:900913

WFS Response

So this is a typical response searching "bob":

	{
	   "type":"FeatureCollection",
	   "features":[
		  {
			 "type":"Feature",
			 "id":"archsites.22",
			 "geometry":{
				"type":"Point",
				"coordinates":[
				   -1.1551632581004398E7,
				   5530530.970137097
				]
			 },
			 "geometry_name":"the_geom",
			 "properties":{
				"cat":22,
				"str1":"Bob Miller"
			 }
		  }
	   ],
	   "crs":{
		  "type":"EPSG",
		  "properties":{
			 "code":"900913"
		  }
	   }
	}

note the properties.cat and properties.str1 and relative recordModel configuration object.

⚠️ **GitHub.com Fallback** ⚠️