import SearchSource from "@arcgis/core/widgets/Search/SearchSource.js";const SearchSource = await $arcgis.import("@arcgis/core/widgets/Search/SearchSource.js");- Inheritance:
- SearchSource→
Accessor
- 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
Search widget - Deprecated since 4.33. Use the Search component instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
SymbolUnion | null | undefined | | |
| | ||
| | ||
uid readonly inherited | ||
| | ||
| |
filter
- 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
- 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.
getSuggestions
- 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.
popupTemplate
- 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
- Type
- string
Specify this to prefix the user's input of the search text.
- Default value
- ""
resultGraphicEnabled
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
- 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
- Type
- string
Specify this to add a suffix to the user's input for the search value.
- Default value
- ""
uid
- Type
- string
- 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
- Type
- boolean
Indicates whether to constrain the search results to the view's extent.
- Default value
- false
Methods
fromJSON
- Signature
-
fromJSON (json: any): any
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | 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
- Signature
-
toJSON (): any
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.