SearchSource

AMD: require(["esri/widgets/Search/SearchSource"], (SearchSource) => { /* code goes here */ });
ESM: import SearchSource from "@arcgis/core/widgets/Search/SearchSource.js";
Class: esri/widgets/Search/SearchSource
Inheritance: SearchSource Accessor
Since: ArcGIS Maps SDK for JavaScript 4.0

The following properties define generic sources properties for use in the Search widget. Please see the sublasses that extend this class for more information about working with Search widget sources.

See also

Constructors

SearchSource

Constructor
new SearchSource(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Boolean

Indicates whether to automatically navigate to the selected result once selected.

SearchSource
String

The name of the class.

Accessor
Object

For filtering suggests or search results.

SearchSource
GetResultsHandler

Function used to get search results.

SearchSource
GetSuggestionsParameters

Function used to get search suggestions.

SearchSource
Number

Indicates the maximum number of search results to return.

SearchSource
Number

Indicates the maximum number of suggestions to return for the widget's input.

SearchSource
Number

Indicates the minimum number of characters required before querying for a suggestion.

SearchSource
String[]

Specifies the fields returned with the search results.

SearchSource
String

Used as a hint for the source input text.

SearchSource
Boolean

Indicates whether to display a Popup when a selected result is clicked.

SearchSource
PopupTemplate

The popup template used to display search results.

SearchSource
String

Specify this to prefix the user's input of the search text.

SearchSource
Boolean

Indicates whether to show a graphic on the map for the selected source using the resultSymbol.

SearchSource
Symbol

The symbol used to display the result.

SearchSource
String

Specify this to add a suffix to the user's input for the search value.

SearchSource
Boolean

Indicates whether to display suggestions as the user enters input text in the widget.

SearchSource
Boolean

Indicates whether to constrain the search results to the view's extent.

SearchSource
Number

The set zoom scale for the resulting search result.

SearchSource

Property Details

autoNavigate

Property
autoNavigate Boolean

Indicates whether to automatically navigate to the selected result once selected.

Default Value:true

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.

The name of the class. The declared class name is formatted as esri.folder.className.

filter

Property
filter Object
Since: ArcGIS Maps SDK for JavaScript 4.4 SearchSource since 4.0, filter added at 4.4.

For filtering suggests or search results. Setting a value here takes precedence over withinViewEnabled. Please see the object specification table below for details.

Properties
where String
optional

The where clause specified for filtering suggests or search results.

geometry Geometry
optional

The filter geometry for suggests or search results. Extent is the only supported geometry when working with locator sources. See Find Address Candidates for additional information.

Example
const theExtent = new Extent({
  xmin: 11376463,
  ymin: -5163501,
  xmax: 18890529,
  ymax: -662888,
  spatialReference: {
    wkid: 3857
  }
});

const searchExtent = {
  geometry: theExtent,
  where: "TERRITORY = 'Northern Territory'"
};

const sources = [{
  layer: featureLayerTourism,
  placeholder: "Darwin",
  maxResults: 5,
  searchFields: ["POI"],
  displayField: "POI",
  name: "In a Sunburned Country",
  filter: searchExtent
}];

const searchWidget = new Search({
  view: view,
  sources: sources
});

getResults

Property
getResults GetResultsHandler

Function used to get search results. See GetResultsHandler for the function definition. When resolved, returns an object containing an array of search results.

Default Value:null
See also

getSuggestions

Property
getSuggestions GetSuggestionsParameters

Function used to get search suggestions. See GetSuggestionsParameters for the function definition. When resolved, returns an object containing an array of suggest results.

Default Value:null
See also

maxResults

Property
maxResults Number

Indicates the maximum number of search results to return.

Default Value:6

maxSuggestions

Property
maxSuggestions Number

Indicates the maximum number of suggestions to return for the widget's input.

Default Value:6

minSuggestCharacters

Property
minSuggestCharacters Number

Indicates the minimum number of characters required before querying for a suggestion.

Default Value:1

outFields

Property
outFields String[]

Specifies the fields returned with the search results.

placeholder

Property
placeholder String

Used as a hint for the source input text.

popupEnabled

Property
popupEnabled Boolean

Indicates whether to display a Popup when a selected result is clicked.

popupTemplate

Property
popupTemplate PopupTemplate

The popup template used to display search results. If no popup is needed, set the source's popupTemplate to null.

This property should be set in instances where there is no existing PopupTemplate configured. For example, feature sources will default to any existing popupTemplate configured on the layer.

prefix

Property
prefix String

Specify this to prefix the user's input of the search text.

resultGraphicEnabled

Property
resultGraphicEnabled Boolean

Indicates whether to show a graphic on the map for the selected source using the resultSymbol.

resultSymbol

Property
resultSymbol Symbol

The symbol used to display the result.

Known Limitations

This property only applies when the layer/locator/source is not part of the map.

suffix

Property
suffix String

Specify this to add a suffix to the user's input for the search value.

suggestionsEnabled

Property
suggestionsEnabled Boolean

Indicates whether to display suggestions as the user enters input text in the widget.

Default Value:true

withinViewEnabled

Property
withinViewEnabled Boolean

Indicates whether to constrain the search results to the view's extent.

Default Value:false

zoomScale

Property
zoomScale Number

The set zoom scale for the resulting search result. This scale is automatically honored.

Default Value:null
Example
let searchWidget = new Search({
  view: view,
  sources: [
    {
      layer: featureLayer,
      searchFields: ["Name", "Team"],
      name: "LayerSearchSource",
      zoomScale: 500000
    }
  ]
});

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor
*

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

SearchSource
Boolean

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor
Object

Converts an instance of this class to its ArcGIS portal JSON representation.

SearchSource

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

fromJSON

Method
fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
Type Description
* Returns a new instance of this class.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

toJSON

Method
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

Type Definitions

GetResultsHandler

Type Definition
GetResultsHandler(params){Promise<SearchResult[]>}

Function definition for the getResults property.

Parameters
Specification
params Object

An object that is passed as a parameter to get search results.

Specification
exactMatch Boolean
optional

The key field used to find the result.

location Point
optional

The location value used by the Search.

maxResults Number
optional

Indicates the maximum number of search results to return.

sourceIndex Number
optional

Indicates the index of the search source.

spatialReference SpatialReference
optional

Indicates the Spatial Reference defined by the source.

suggestResult SuggestResult

Indicates the Suggest Result that triggered the search for a result.

optional

Indicates the view provided to the Search Widget using the source.

Returns
Type Description
Promise<SearchResult[]> When resolved, returns an object containing an array of search results.

GetSuggestionsParameters

Type Definition
GetSuggestionsParameters(params){Promise<SuggestResult[]>}

Function definition for the getSuggestions() property.

Parameters
Specification
params Object

An object that is passed as a parameter to get search suggestions.

Specification
maxSuggestions Number
optional

Indicates the maximum number of suggestions to return for the widget's input.

sourceIndex Number
optional

Indicates the index of the search source.

spatialReference SpatialReference
optional

Indicates the spatial reference defined by the source.

suggestTerm String
optional

Indicates search term used to find a suggestion.

optional

Indicates the view provided to the Search Widget using the source.

Returns
Type Description
Promise<SuggestResult[]> When resolved, returns an object containing an array of suggest results.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.