Skip to content
import SearchSource from "@arcgis/core/widgets/Search/SearchSource.js";
Inheritance:
SearchSourceAccessor
Subclasses:
LayerSearchSource, LocatorSearchSource
Since
ArcGIS Maps SDK for JavaScript 4.0

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

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

autoNavigate

Property
Type
boolean | null | undefined

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

Default value
true

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

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

filter

Property
Type
SearchFilter | null | undefined
Since
ArcGIS Maps SDK for JavaScript 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.

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
Type
GetResultsCallback | null | undefined

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

See also

getSuggestions

Property
Type
GetSuggestionsCallback | null | undefined

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

See also

maxResults

Property
Type
number | null | undefined

Indicates the maximum number of search results to return.

Default value
6

maxSuggestions

Property
Type
number | null | undefined

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

Default value
6

minSuggestCharacters

Property
Type
number | null | undefined

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

outFields

Property
Type
string[] | null | undefined

Specifies the fields returned with the search results.

placeholder

Property
Type
string | null | undefined

Used as a hint for the source input text.

Default value
""

popupEnabled

Property
Type
boolean | null | undefined

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

popupTemplate

autocast Property
Type
PopupTemplate | null | undefined

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 FeatureLayer.popupTemplate configured on the layer.

prefix

Property
Type
string

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

Default value
""

resultGraphicEnabled

Property
Type
boolean | null | undefined

Indicates whether to show a graphic on the map for the selected source using the resultSymbol. If using a LayerSearchSource, then this property only applies when the LayerSearchSource is not part of the map.

resultSymbol

Property
Type
SymbolUnion | null | undefined

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
Type
string

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

Default value
""

suggestionsEnabled

Property
Type
boolean | null | undefined

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

Default value
true

uid

readonlyinherited Property
Type
string
Inherited from: IdentifiableMixin
Since
ArcGIS Maps SDK for JavaScript 4.33

An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.

withinViewEnabled

Property
Type
boolean

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

Default value
false

zoomScale

Property
Type
number | null | undefined

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

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

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

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.

Parameters
ParameterTypeDescriptionRequired
json
any

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
any

Returns a new instance of this class.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

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

Returns
any

The ArcGIS portal JSON representation of an instance of this class.