Web AppBuilder for ArcGIS (Developer Edition)

Search

The Search widget provides a way to perform search capabilities based on locator services, map service feature layers, and feature service feature layers. These specified sources determine what is searchable in the search box. If you're using a locator with a geocoding service, the findAddressCandidates operation is used, whereas queries are used on feature layers.

The Search widget replaces the Geocoder widget. The main difference is that the Search widget provides additional functionality that allows searching and suggestions on multiple sources.

The following table lists the configurable attributes of the Search widget:

AttributeDescription
allPlaceholder

String. Displays the placeholder text when users select All from the source list.

showInfoWindowOnSelect

Boolean. Indicates whether to show the infoWindow when a result is selected.

Sources

Object[]. There is no default. An array of source objects used to find search results. See the ArcGIS API for Java Script sources property for details.

  • type—String. Applies to both locators and feature layer sources. This is the type of the source. Currently supports locator and query only.
  • name—String. Applies to both locators and feature layer sources. This is the name of the source for display.
  • url—String. Applies to both locators and feature layer sources. This is the URL of the source for search.
  • placeholder—String. Applies to both locators and feature layer sources. This is used as a hint for the source input text.
  • maxResults—Number. Applies to both locators and feature layer sources. This indicates the maximum number of results to return. The default value is 6.
  • singleLineFieldName—String. Applies only when working with locator sources. The singleLineFieldName of geocode service.
  • countryCode—String. Applies only when working with locator sources. This constricts search results to a specified country code. For example, "US" for United States or "SE" for Sweden. Only applies to the World Geocode Service.
  • searchFields—String[]. Applies only to feature layer sources. It is an array of string values to search for results in these feature layer fields.
  • displayField—String. Applies only to feature layer sources. The results are displayed using this field. The default is the layer's displayField or the first string field.
  • exactMatch—Boolean. Applies only to feature layer sources. This returns results that match the search value exactly. The default is false.
  • layerId—String. Applies only to feature layer sources. The ID of the layer in the current map. If the feature layer isn't from the map, this property will be deleted.

Example:

{
		"allPlaceholder": "All Cities",
  "showInfoWindowOnSelect": true,
  "sources": [{
    "url": "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",
    "name": "Esri World Geocoder",
    "singleLineFieldName": "SingleLine",
    "placeholder": "Esri World Geocoder",
    "countryCode": "",
    "maxResults": 6,
    "type": "locator"
  }, {
    "layerId": "DistributionFacilities_4577",
    "url": "http://tmelectric.esri.com/arcgis/rest/services/DistributionFacilities/MapServer/13",
    "name": "DistributionFacilities - Pole",
    "placeholder": "Pole",
    "searchFields": ["FACILITYID"],
    "displayField": "FACILITYID",
    "exactMatch": false,
    "maxResults": 6,
    "type": "query"
  }]
}