LayerSearchSource

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

The following properties define a Layer-based source whose features may be searched by a Search widget instance.

For string field searches, there is no leading wildcard. This effectively makes exactMatch true, which will remove unnecessary search results and suggestions.

Layers created from client-side graphics are not supported.

See also

Constructors

LayerSearchSource

Constructor
new LayerSearchSource(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

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

SearchSource

The name of the class.

Accessor

The results are displayed using this field.

LayerSearchSource

Indicates to only return results that match the search value exactly.

LayerSearchSource

For filtering suggests or search results.

SearchSource

Function used to get search results.

SearchSource

Function used to get search suggestions.

SearchSource

The layer queried in the search.

LayerSearchSource

Indicates the maximum number of search results to return.

SearchSource

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

SearchSource

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

SearchSource

The name of the source for display.

LayerSearchSource

One or more field names used to order the query results.

LayerSearchSource

Specifies the fields returned with the search results.

SearchSource

Used as a hint for the source input text.

SearchSource

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

SearchSource

The popup template used to display search results.

SearchSource

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

SearchSource

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

SearchSource

The symbol used to display the result.

SearchSource

An array of string values representing the names of fields in the feature layer to search.

LayerSearchSource

A template string used to display multiple fields in a defined order when results are displayed.

LayerSearchSource

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

SearchSource

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

SearchSource

A template string used to display multiple fields in a defined order when suggestions are displayed.

LayerSearchSource

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

SearchSource

The set zoom scale for the resulting search result.

SearchSource

Property Details

autoNavigate

Inherited
Property
autoNavigate Boolean
Inherited from SearchSource

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

Default Value:true

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

displayField

Property
displayField String

The results are displayed using this field. Defaults to the layer's displayField or the first string field.

exactMatch

Property
exactMatch Boolean

Indicates to only return results that match the search value exactly. This property only applies to string field searches. exactMatch is always true when searching fields of type number.

Default Value:false

filter

Inherited
Property
filter Object
Inherited from SearchSource

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

Inherited
Property
getResults GetResultsHandler
Inherited from SearchSource

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

Inherited
Property
getSuggestions GetSuggestionsParameters
Inherited from SearchSource

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

layer

Property
layer Layer

The layer queried in the search. This is required. The layer can be a map/feature service feature layer(s), SceneLayers with an associated feature layer, BuildingComponentSublayer with an associated feature layer, GeoJSONLayer, CSVLayer or OGCFeatureLayer. See the SceneLayer Guide page on how to publish SceneLayers with associated feature layers.

The geometry type of the layer affects the behavior when a result is found. If the layer type is Point, the view will pan, but not zoom, to the result. If the layer type is Polygon or Polyline, the view will pan and zoom to the result.

Feature layers created from client-side graphics are not supported.

maxResults

Inherited
Property
maxResults Number
Inherited from SearchSource

Indicates the maximum number of search results to return.

Default Value:6

maxSuggestions

Inherited
Property
maxSuggestions Number
Inherited from SearchSource

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

Default Value:6

minSuggestCharacters

Inherited
Property
minSuggestCharacters Number
Inherited from SearchSource

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

Default Value:1

name

Property
name String

The name of the source for display.

orderByFields

Property
orderByFields String[]

One or more field names used to order the query results. Specify ASC (ascending) or DESC (descending) after the field name to control the order. The default order is ASC.

outFields

Inherited
Property
outFields String[]
Inherited from SearchSource

Specifies the fields returned with the search results.

placeholder

Inherited
Property
placeholder String
Inherited from SearchSource

Used as a hint for the source input text.

popupEnabled

Inherited
Property
popupEnabled Boolean
Inherited from SearchSource

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

popupTemplate

Inherited
Property
popupTemplate PopupTemplate
Inherited from SearchSource

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

Inherited
Property
prefix String
Inherited from SearchSource

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

resultGraphicEnabled

Inherited
Property
resultGraphicEnabled Boolean
Inherited from SearchSource

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

resultSymbol

Inherited
Property
resultSymbol Symbol
Inherited from SearchSource

The symbol used to display the result.

Known Limitations

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

searchFields

Property
searchFields String[]

An array of string values representing the names of fields in the feature layer to search.

searchTemplate

Property
searchTemplate String

A template string used to display multiple fields in a defined order when results are displayed.

Example
LayerSearchSource.searchTemplate = "{County}, {State}";

suffix

Inherited
Property
suffix String
Inherited from SearchSource

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

suggestionsEnabled

Inherited
Property
suggestionsEnabled Boolean
Inherited from SearchSource

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

Default Value:true

suggestionTemplate

Property
suggestionTemplate String

A template string used to display multiple fields in a defined order when suggestions are displayed. This takes precedence over displayField. Field names in the template must have the following format: {FieldName}. An example suggestionTemplate could look something like: Name: {OWNER}, Parcel: {PARCEL_ID}.

Example
LayerSearchSource.suggestionTemplate = "Name: {OWNER}, Parcel: {PARCEL_ID}";

withinViewEnabled

Inherited
Property
withinViewEnabled Boolean
Inherited from SearchSource

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

Default Value:false

zoomScale

Inherited
Property
zoomScale Number
Inherited from SearchSource

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 deep clone of this object.

LayerSearchSource
*

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

LayerSearchSource

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

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

LayerSearchSource

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.

clone

Method
clone(){LayerSearchSource}

Creates a deep clone of this object.

Returns
Type Description
LayerSearchSource A clone of the new LayerSearchSource instance.

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.

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